Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| HintStream | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
9 / 9 |
|
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\PdfNumber; |
| 9 | use Phpdftk\Pdf\Core\PdfStream; |
| 10 | |
| 11 | /** |
| 12 | * Primary hint stream — ISO 32000-2 §F.3.1. |
| 13 | * |
| 14 | * A stream whose dictionary contains hint-table offsets (P, S, T, O, |
| 15 | * A, E, V, I, C, L, R, B) pointing into the body of the stream. Used |
| 16 | * by linearized PDFs to speed up progressive rendering. |
| 17 | * |
| 18 | * Object-model only; not emitted by `PdfWriter`. |
| 19 | */ |
| 20 | class HintStream extends PdfStream |
| 21 | { |
| 22 | public ?int $p = null; // /P pages hint table offset |
| 23 | public ?int $s = null; // /S shared-object hint table offset |
| 24 | public ?int $t = null; // /T thumbnail hint table offset |
| 25 | public ?int $o = null; // /O outline |
| 26 | public ?int $a = null; // /A thread |
| 27 | public ?int $e = null; // /E named-destination |
| 28 | public ?int $v = null; // /V interactive-form |
| 29 | public ?int $i = null; // /I info |
| 30 | public ?int $c = null; // /C logical-structure |
| 31 | public ?int $l = null; // /L page label |
| 32 | public ?int $r = null; // /R renditions |
| 33 | public ?int $b = null; // /B embedded files |
| 34 | |
| 35 | public function __construct(string $data = '') |
| 36 | { |
| 37 | parent::__construct(new PdfDictionary(), $data); |
| 38 | } |
| 39 | |
| 40 | public function toPdf(): string |
| 41 | { |
| 42 | foreach ([ |
| 43 | 'P' => $this->p, 'S' => $this->s, 'T' => $this->t, |
| 44 | 'O' => $this->o, 'A' => $this->a, 'E' => $this->e, |
| 45 | 'V' => $this->v, 'I' => $this->i, 'C' => $this->c, |
| 46 | 'L' => $this->l, 'R' => $this->r, 'B' => $this->b, |
| 47 | ] as $key => $value) { |
| 48 | if ($value !== null) { |
| 49 | $this->dictionary->set($key, new PdfNumber($value)); |
| 50 | } |
| 51 | } |
| 52 | return parent::toPdf(); |
| 53 | } |
| 54 | } |