Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| WidgetAnnotation | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
7 | |
100.00% |
1 / 1 |
| getSubtype | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Annotation; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfName; |
| 8 | use Phpdftk\Pdf\Core\PdfReference; |
| 9 | use Phpdftk\Pdf\Core\PdfVersion; |
| 10 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 11 | |
| 12 | /** |
| 13 | * Widget annotation (/Subtype /Widget). |
| 14 | * Used to represent interactive form fields on a page. |
| 15 | */ |
| 16 | #[RequiresPdfVersion(PdfVersion::V1_2)] |
| 17 | class WidgetAnnotation extends Annotation |
| 18 | { |
| 19 | public ?PdfName $h = null; // /H - highlight mode |
| 20 | public ?PdfReference $mk = null; // /MK - appearance characteristics |
| 21 | public ?PdfReference $a = null; // /A - action |
| 22 | public ?PdfReference $aa = null; // /AA - additional actions |
| 23 | public ?PdfReference $parent = null; // /Parent |
| 24 | |
| 25 | public function getSubtype(): string |
| 26 | { |
| 27 | return 'Widget'; |
| 28 | } |
| 29 | |
| 30 | public function toPdf(): string |
| 31 | { |
| 32 | $dict = $this->buildDictionary(); |
| 33 | |
| 34 | if ($this->h !== null) { |
| 35 | $dict->set('H', $this->h); |
| 36 | } |
| 37 | if ($this->mk !== null) { |
| 38 | $dict->set('MK', $this->mk); |
| 39 | } |
| 40 | if ($this->a !== null) { |
| 41 | $dict->set('A', $this->a); |
| 42 | } |
| 43 | if ($this->aa !== null) { |
| 44 | $dict->set('AA', $this->aa); |
| 45 | } |
| 46 | if ($this->parent !== null) { |
| 47 | $dict->set('Parent', $this->parent); |
| 48 | } |
| 49 | |
| 50 | return $dict->toPdf(); |
| 51 | } |
| 52 | } |