Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| NamesDictionary | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
11 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
11 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfObject; |
| 9 | use Phpdftk\Pdf\Core\PdfReference; |
| 10 | use Phpdftk\Pdf\Core\PdfVersion; |
| 11 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 12 | |
| 13 | /** |
| 14 | * Document Names dictionary — ISO 32000-2 §7.7.4, Table 33. |
| 15 | * |
| 16 | * Referenced from `Catalog::$names`. Each entry is a reference to a |
| 17 | * name tree mapping a string key to the relevant object type. |
| 18 | */ |
| 19 | #[RequiresPdfVersion(PdfVersion::V1_4)] |
| 20 | class NamesDictionary extends PdfObject |
| 21 | { |
| 22 | public ?PdfReference $dests = null; // /Dests |
| 23 | public ?PdfReference $ap = null; // /AP |
| 24 | public ?PdfReference $javaScript = null; // /JavaScript |
| 25 | public ?PdfReference $pages = null; // /Pages |
| 26 | public ?PdfReference $templates = null; // /Templates |
| 27 | public ?PdfReference $ids = null; // /IDS |
| 28 | public ?PdfReference $urls = null; // /URLS |
| 29 | public ?PdfReference $embeddedFiles = null; // /EmbeddedFiles |
| 30 | public ?PdfReference $alternatePresentations = null; // /AlternatePresentations |
| 31 | public ?PdfReference $renditions = null; // /Renditions |
| 32 | |
| 33 | public function toPdf(): string |
| 34 | { |
| 35 | $dict = new PdfDictionary(); |
| 36 | if ($this->dests !== null) { |
| 37 | $dict->set('Dests', $this->dests); |
| 38 | } |
| 39 | if ($this->ap !== null) { |
| 40 | $dict->set('AP', $this->ap); |
| 41 | } |
| 42 | if ($this->javaScript !== null) { |
| 43 | $dict->set('JavaScript', $this->javaScript); |
| 44 | } |
| 45 | if ($this->pages !== null) { |
| 46 | $dict->set('Pages', $this->pages); |
| 47 | } |
| 48 | if ($this->templates !== null) { |
| 49 | $dict->set('Templates', $this->templates); |
| 50 | } |
| 51 | if ($this->ids !== null) { |
| 52 | $dict->set('IDS', $this->ids); |
| 53 | } |
| 54 | if ($this->urls !== null) { |
| 55 | $dict->set('URLS', $this->urls); |
| 56 | } |
| 57 | if ($this->embeddedFiles !== null) { |
| 58 | $dict->set('EmbeddedFiles', $this->embeddedFiles); |
| 59 | } |
| 60 | if ($this->alternatePresentations !== null) { |
| 61 | $dict->set('AlternatePresentations', $this->alternatePresentations); |
| 62 | } |
| 63 | if ($this->renditions !== null) { |
| 64 | $dict->set('Renditions', $this->renditions); |
| 65 | } |
| 66 | return $dict->toPdf(); |
| 67 | } |
| 68 | } |