Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| HideAction | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getActionType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Action; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfBoolean; |
| 9 | use Phpdftk\Pdf\Core\PdfReference; |
| 10 | use Phpdftk\Pdf\Core\PdfString; |
| 11 | use Phpdftk\Pdf\Core\PdfVersion; |
| 12 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 13 | |
| 14 | /** |
| 15 | * Hide action (/S /Hide) โ ISO 32000-2 ยง12.6.4.10. |
| 16 | * Sets the Hidden flag on one or more annotations or form fields. |
| 17 | */ |
| 18 | #[RequiresPdfVersion(PdfVersion::V1_2)] |
| 19 | class HideAction extends Action |
| 20 | { |
| 21 | /** /T โ a single target or an array of targets. */ |
| 22 | public PdfString|PdfArray|PdfReference $t; |
| 23 | public bool $h = true; // /H โ true = hide, false = show |
| 24 | |
| 25 | public function __construct(PdfString|PdfArray|PdfReference $t, bool $hide = true) |
| 26 | { |
| 27 | $this->t = $t; |
| 28 | $this->h = $hide; |
| 29 | } |
| 30 | |
| 31 | public function getActionType(): string |
| 32 | { |
| 33 | return 'Hide'; |
| 34 | } |
| 35 | |
| 36 | public function toPdf(): string |
| 37 | { |
| 38 | $dict = $this->baseDictionary(); |
| 39 | $dict->set('T', $this->t); |
| 40 | $dict->set('H', new PdfBoolean($this->h)); |
| 41 | return $dict->toPdf(); |
| 42 | } |
| 43 | } |