Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
95.45% |
21 / 22 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| MarkupAnnotation | |
95.45% |
21 / 22 |
|
0.00% |
0 / 1 |
11 | |
0.00% |
0 / 1 |
| buildDictionary | |
95.45% |
21 / 22 |
|
0.00% |
0 / 1 |
11 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Annotation; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfName; |
| 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 | * Shared base for markup annotations — ISO 32000-2 §12.5.6.2, Table 170. |
| 16 | * |
| 17 | * Markup annotations are the subset of annotations that represent |
| 18 | * user-authored commentary on the document (Text, FreeText, Line, |
| 19 | * Square, Circle, Polygon, PolyLine, Highlight, Underline, Squiggly, |
| 20 | * StrikeOut, Stamp, Caret, Ink, FileAttachment, Sound, Redact). They |
| 21 | * share a set of fields beyond the base annotation dictionary for |
| 22 | * authoring metadata, threaded replies, popup windows, and rich content. |
| 23 | * |
| 24 | * Non-markup annotations (Link, Popup, Widget, Screen, PrinterMark, |
| 25 | * TrapNet, Watermark, 3D, Projection, RichMedia, Movie) keep extending |
| 26 | * {@see Annotation} directly. |
| 27 | */ |
| 28 | #[RequiresPdfVersion(PdfVersion::V1_4)] |
| 29 | abstract class MarkupAnnotation extends Annotation |
| 30 | { |
| 31 | public ?PdfString $t = null; // /T text label (author) |
| 32 | public ?PdfReference $popup = null; // /Popup associated popup annotation |
| 33 | public ?float $markupCa = null; // /CA constant opacity (markup override) |
| 34 | public ?PdfString $rc = null; // /RC rich content (XFA-style XML) |
| 35 | public ?PdfString $creationDate = null; // /CreationDate |
| 36 | public ?PdfReference $irt = null; // /IRT in-reply-to annotation |
| 37 | public ?PdfString $subj = null; // /Subj short description |
| 38 | public ?PdfName $rt = null; // /RT reply type: R (reply) or Group |
| 39 | public ?PdfName $it = null; // /IT intent (e.g. FreeTextCallout, LineArrow) |
| 40 | public ?PdfDictionary $exData = null; // /ExData external data dict |
| 41 | |
| 42 | protected function buildDictionary(): PdfDictionary |
| 43 | { |
| 44 | $dict = parent::buildDictionary(); |
| 45 | |
| 46 | if ($this->t !== null) { |
| 47 | $dict->set('T', $this->t); |
| 48 | } |
| 49 | if ($this->popup !== null) { |
| 50 | $dict->set('Popup', $this->popup); |
| 51 | } |
| 52 | if ($this->markupCa !== null) { |
| 53 | $dict->set('CA', new \Phpdftk\Pdf\Core\PdfNumber($this->markupCa)); |
| 54 | } |
| 55 | if ($this->rc !== null) { |
| 56 | $dict->set('RC', $this->rc); |
| 57 | } |
| 58 | if ($this->creationDate !== null) { |
| 59 | $dict->set('CreationDate', $this->creationDate); |
| 60 | } |
| 61 | if ($this->irt !== null) { |
| 62 | $dict->set('IRT', $this->irt); |
| 63 | } |
| 64 | if ($this->subj !== null) { |
| 65 | $dict->set('Subj', $this->subj); |
| 66 | } |
| 67 | if ($this->rt !== null) { |
| 68 | $dict->set('RT', $this->rt); |
| 69 | } |
| 70 | if ($this->it !== null) { |
| 71 | $dict->set('IT', $this->it); |
| 72 | } |
| 73 | if ($this->exData !== null) { |
| 74 | $dict->set('ExData', $this->exData); |
| 75 | } |
| 76 | |
| 77 | return $dict; |
| 78 | } |
| 79 | } |