def __init__(self, parser, password=b'<STR_LIT>', caching=True, fallback=True):
self.caching = caching<EOL>self.xrefs = []<EOL>self.info = []<EOL>self.catalog = None<EOL>self.encryption = None<EOL>self.decipher = None<EOL>self._parser = None<EOL>self._cached_objs = {}<EOL>self._parsed_objs = {}<EOL>self._parser = parser<EOL>self._parser.set_document(self)<EOL>self.is_printable = self.is_modifiable = self.is_extractable = True<EOL>try:<EOL><INDENT>pos = self.find_xref(parser)<EOL>self.read_xref_from(parser, pos, self.xrefs)<EOL><DEDENT>except PDFNoValidXRef:<EOL><INDENT>fallback = True<EOL><DEDENT>if fallback:<EOL><INDENT>parser.fallback = True<EOL>xref = PDFXRefFallback()<EOL>xref.load(parser)<EOL>self.xrefs.append(xref)<EOL><DEDENT>for xref in self.xrefs:<EOL><INDENT>trailer = xref.get_trailer()<EOL>if not trailer:<EOL><INDENT>continue<EOL><DEDENT>if '<STR_LIT>' in trailer:<EOL><INDENT>self.encryption = (list_value(trailer['<STR_LIT>']),<EOL>dict_value(trailer['<STR_LIT>']))<EOL>self._initialize_password(password)<EOL><DEDENT>if '<STR_LIT>' in trailer:<EOL><INDENT>self.info.append(dict_value(trailer['<STR_LIT>']))<EOL><DEDENT>if '<STR_LIT>' in trailer:<EOL><INDENT>self.catalog = dict_value(trailer['<STR_LIT>'])<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise PDFSyntaxError('<STR_LIT>')<EOL><DEDENT>if self.catalog.get('<STR_LIT>') is not LITERAL_CATALOG:<EOL><INDENT>if STRICT:<EOL><INDENT>raise PDFSyntaxError('<STR_LIT>')<EOL><DEDENT><DEDENT>return<EOL>
Set the document to use a given PDFParser object.