Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| LinearizationParameters | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| 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\PdfNumber; |
| 10 | use Phpdftk\Pdf\Core\PdfObject; |
| 11 | |
| 12 | /** |
| 13 | * Linearization parameter dictionary — ISO 32000-2 §F.2.1. |
| 14 | * |
| 15 | * First object in a linearized (web-optimized) PDF file. Describes the |
| 16 | * layout parameters needed by a reader to fetch the document's first |
| 17 | * page and catalog without downloading the entire file. |
| 18 | * |
| 19 | * This class is object-model only; `PdfWriter` does not yet emit |
| 20 | * linearized files. |
| 21 | */ |
| 22 | class LinearizationParameters extends PdfObject |
| 23 | { |
| 24 | public float $linearized = 1.0; // /Linearized - version (always 1) |
| 25 | public int $l = 0; // /L - file length |
| 26 | public PdfArray $h; // /H - hint stream offsets [offset length ...] |
| 27 | public int $o = 0; // /O - first page object number |
| 28 | public int $e = 0; // /E - offset of first page end |
| 29 | public int $n = 0; // /N - number of pages |
| 30 | public int $t = 0; // /T - offset of first xref entry |
| 31 | |
| 32 | public function __construct() |
| 33 | { |
| 34 | $this->h = new PdfArray([]); |
| 35 | } |
| 36 | |
| 37 | public function toPdf(): string |
| 38 | { |
| 39 | $dict = new PdfDictionary(); |
| 40 | $dict->set('Linearized', new PdfNumber($this->linearized)); |
| 41 | $dict->set('L', new PdfNumber($this->l)); |
| 42 | $dict->set('H', $this->h); |
| 43 | $dict->set('O', new PdfNumber($this->o)); |
| 44 | $dict->set('E', new PdfNumber($this->e)); |
| 45 | $dict->set('N', new PdfNumber($this->n)); |
| 46 | $dict->set('T', new PdfNumber($this->t)); |
| 47 | return $dict->toPdf(); |
| 48 | } |
| 49 | } |