'Set the document to use a given PDFParser object.'

def set_parser(self, parser):

    if self._parser:
        return
    self._parser = parser
    self.xrefs = parser.read_xref()
    for xref in self.xrefs:
        trailer = xref.get_trailer()
        if (not trailer):
            continue
        if ('Encrypt' in trailer):
            self.encryption = (list_value(trailer['ID']), dict_value(trailer['Encrypt']))
        if ('Info' in trailer):
            self.info.append(dict_value(trailer['Info']))
        if ('Root' in trailer):
            self.catalog = dict_value(trailer['Root'])
            break
    else:
        raise PDFSyntaxError('No    /Root    object!    -    Is    this    really    a    PDF?')
    if (self.catalog.get('Type') is not LITERAL_CATALOG):
        if STRICT:
            raise PDFSyntaxError('Catalog    not    found!')
    return
