Set the document to use a given PDFParser object.
(self, parser)
| 309 | return |
| 310 | |
| 311 | def set_parser(self, parser): |
| 312 | "Set the document to use a given PDFParser object." |
| 313 | if self._parser: return |
| 314 | self._parser = parser |
| 315 | # Retrieve the information of each header that was appended |
| 316 | # (maybe multiple times) at the end of the document. |
| 317 | self.xrefs = parser.read_xref() |
| 318 | for xref in self.xrefs: |
| 319 | trailer = xref.get_trailer() |
| 320 | if not trailer: continue |
| 321 | # If there's an encryption info, remember it. |
| 322 | if 'Encrypt' in trailer: |
| 323 | #assert not self.encryption |
| 324 | self.encryption = (list_value(trailer['ID']), |
| 325 | dict_value(trailer['Encrypt'])) |
| 326 | if 'Info' in trailer: |
| 327 | self.info.append(dict_value(trailer['Info'])) |
| 328 | if 'Root' in trailer: |
| 329 | # Every PDF file must have exactly one /Root dictionary. |
| 330 | self.catalog = dict_value(trailer['Root']) |
| 331 | break |
| 332 | else: |
| 333 | raise PDFSyntaxError('No /Root object! - Is this really a PDF?') |
| 334 | if self.catalog.get('Type') is not LITERAL_CATALOG: |
| 335 | if STRICT: |
| 336 | raise PDFSyntaxError('Catalog not found!') |
| 337 | return |
| 338 | |
| 339 | # initialize(password='') |
| 340 | # Perform the initialization with a given password. |
no test coverage detected