Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ObjectRef | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
| 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\PdfName; |
| 9 | use Phpdftk\Pdf\Core\PdfObject; |
| 10 | use Phpdftk\Pdf\Core\PdfReference; |
| 11 | use Phpdftk\Pdf\Core\PdfVersion; |
| 12 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 13 | |
| 14 | /** |
| 15 | * PDF Object Reference dictionary (ISO 32000-2 Table 326). |
| 16 | * |
| 17 | * References a PDF object (such as an annotation or XObject) from |
| 18 | * the structure tree. |
| 19 | * |
| 20 | * Example: |
| 21 | * $objRef = new ObjectRef(); |
| 22 | * $objRef->pg = new PdfReference($page->objectNumber); |
| 23 | * $objRef->obj = new PdfReference($annotation->objectNumber); |
| 24 | */ |
| 25 | #[RequiresPdfVersion(PdfVersion::V1_5)] |
| 26 | class ObjectRef extends PdfObject |
| 27 | { |
| 28 | public const PDF_TYPE = 'OBJR'; |
| 29 | |
| 30 | public ?PdfReference $pg = null; // /Pg - page |
| 31 | public ?PdfReference $obj = null; // /Obj - referenced object |
| 32 | |
| 33 | public function toPdf(): string |
| 34 | { |
| 35 | $dict = new PdfDictionary(); |
| 36 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 37 | |
| 38 | if ($this->pg !== null) { |
| 39 | $dict->set('Pg', $this->pg); |
| 40 | } |
| 41 | if ($this->obj !== null) { |
| 42 | $dict->set('Obj', $this->obj); |
| 43 | } |
| 44 | |
| 45 | return $dict->toPdf(); |
| 46 | } |
| 47 | } |