Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Bead | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
6 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfObject; |
| 11 | use Phpdftk\Pdf\Core\PdfReference; |
| 12 | use Phpdftk\Pdf\Core\PdfVersion; |
| 13 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 14 | |
| 15 | /** |
| 16 | * Article bead dictionary (ISO 32000-2 Table 161). |
| 17 | * |
| 18 | * Represents a single bead in an article thread, linking to a specific |
| 19 | * region on a page and chaining to adjacent beads. |
| 20 | */ |
| 21 | #[RequiresPdfVersion(PdfVersion::V1_1)] |
| 22 | class Bead extends PdfObject |
| 23 | { |
| 24 | public const PDF_TYPE = 'Bead'; |
| 25 | |
| 26 | public ?PdfReference $t = null; // /T - parent thread |
| 27 | public ?PdfReference $n = null; // /N - next bead |
| 28 | public ?PdfReference $v = null; // /V - previous bead |
| 29 | public ?PdfReference $p = null; // /P - page |
| 30 | public ?PdfArray $r = null; // /R - rectangle |
| 31 | |
| 32 | public function toPdf(): string |
| 33 | { |
| 34 | $dict = new PdfDictionary(); |
| 35 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 36 | |
| 37 | if ($this->t !== null) { |
| 38 | $dict->set('T', $this->t); |
| 39 | } |
| 40 | if ($this->n !== null) { |
| 41 | $dict->set('N', $this->n); |
| 42 | } |
| 43 | if ($this->v !== null) { |
| 44 | $dict->set('V', $this->v); |
| 45 | } |
| 46 | if ($this->p !== null) { |
| 47 | $dict->set('P', $this->p); |
| 48 | } |
| 49 | if ($this->r !== null) { |
| 50 | $dict->set('R', $this->r); |
| 51 | } |
| 52 | |
| 53 | return $dict->toPdf(); |
| 54 | } |
| 55 | } |