1 | <?php |
||
16 | class DocumentWriter |
||
17 | { |
||
18 | /** |
||
19 | * @var ObjectWriter |
||
20 | */ |
||
21 | private $objectWriter; |
||
22 | |||
23 | /** |
||
24 | * @var PdfWriterOptions |
||
25 | */ |
||
26 | private $options; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | private $permanentFileIdentifier; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $changingFileIdentifier; |
||
37 | |||
38 | /** |
||
39 | * @var int |
||
40 | */ |
||
41 | private $pageTreeId; |
||
42 | |||
43 | /** |
||
44 | * @var PageWriter[] |
||
45 | */ |
||
46 | private $pageWriters = []; |
||
47 | |||
48 | /** |
||
49 | * @var int[] |
||
50 | */ |
||
51 | private $pageIds = []; |
||
52 | |||
53 | /** |
||
54 | * @var DocumentInformation |
||
55 | */ |
||
56 | private $documentInformation; |
||
57 | |||
58 | /** |
||
59 | * @param ObjectWriter $objectWriter |
||
60 | * @param string $fileIdentifier |
||
61 | */ |
||
62 | public function __construct(ObjectWriter $objectWriter, PdfWriterOptions $options, $fileIdentifier) |
||
74 | |||
75 | /** |
||
76 | * Returns the document information object. |
||
77 | * |
||
78 | * @return DocumentInformation |
||
79 | */ |
||
80 | public function getDocumentInformation() |
||
84 | |||
85 | /** |
||
86 | * Adds a page writer for the page tree. |
||
87 | * |
||
88 | * @param PageWriter $pageWriter |
||
89 | */ |
||
90 | public function addPageWriter(PageWriter $pageWriter) |
||
94 | |||
95 | /** |
||
96 | * Ends the document. |
||
97 | * |
||
98 | * @param EncryptionInterface $encryption |
||
99 | */ |
||
100 | public function endDocument(EncryptionInterface $encryption) |
||
111 | |||
112 | /** |
||
113 | * Closes pages which haven't been explicitly closed yet. |
||
114 | */ |
||
115 | private function closeRemainingPages() |
||
122 | |||
123 | /** |
||
124 | * Writes the page tree. |
||
125 | */ |
||
126 | private function writePageTree() |
||
150 | |||
151 | /** |
||
152 | * Writes the document information. |
||
153 | * |
||
154 | * @return int |
||
155 | */ |
||
156 | private function writeDocumentInformation() |
||
163 | |||
164 | /** |
||
165 | * Writes the document catalog. |
||
166 | * |
||
167 | * @return int |
||
168 | */ |
||
169 | private function writeDocumentCatalog() |
||
184 | |||
185 | /** |
||
186 | * Writes the cross-reference table. |
||
187 | * |
||
188 | * @return int |
||
189 | */ |
||
190 | private function writeCrossReferenceTable() |
||
206 | |||
207 | /** |
||
208 | * Writes the trailer. |
||
209 | * |
||
210 | * @param int $documentInformationId |
||
211 | * @param int $documentCatalogId |
||
212 | * @param EncryptionInterface $encryption |
||
213 | */ |
||
214 | private function writeTrailer($documentInformationId, $documentCatalogId, EncryptionInterface $encryption) |
||
235 | |||
236 | /** |
||
237 | * Writes the footer. |
||
238 | * |
||
239 | * @param int $xrefOffset |
||
240 | */ |
||
241 | private function writeFooter($xrefOffset) |
||
248 | } |
||
249 |