def read(self, stream, password=''): """ Function which overrides 'read' of PdfFileReader class """ PdfFileReader.read2(self, stream) PdfStructureMixin.read(self, stream) # Decrypt automatically with password if self.getIsEncrypted(): print 'Document is encrypted. Trying to decrypt...' ret = self.decrypt(password) if ret: print 'Document decryption success.' else: print 'Document decryption failed.' raise DecryptionFailedException # Fill in document information self.fillInfo() # Set the root object self.root = self.trailer['/Root'].getObject()