Exemplo n.º 1
0
    def read(self):
        """ Function which overrides 'read' of PdfFileReader class """

        # PdfFileReader.read2(self, stream)
        PdfFileReader.read(self, self.stream)
        PdfStructureMixin.read(self, self.stream)
        # Decrypt automatically with password
        if self.getIsEncrypted():
            self.logger.info('Document is encrypted. Trying to decrypt')
            ret = self.decrypt(self.passwd)
            if ret:
                self.logger.info('Document decryption success.')
            else:
                self.logger.error('Document decryption failed.')
                raise DecryptionFailedException

        # Fill in document information
        self.fillInfo()
        # Set the root object
        self.root = self.trailer['/Root'].getObject()