pyPdf fails to read non-encrypted document raising "file has not been decrypted"

Bug #355479 reported by logari81
4
Affects Status Importance Assigned to Milestone
pyPdf
New
Undecided
Unassigned

Bug Description

Trying to get a reference of the first page of the attached pdf document raises the exception "file has not been decrypted" even though the document is not encrypted. See below:

>>> input = pyPdf.PdfFileReader(file("DS-0157.pdf",'rb'))
>>> page = input.getPage(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.6/pyPdf/pdf.py", line 353, in getPage
    self._flatten()
  File "/var/lib/python-support/python2.6/pyPdf/pdf.py", line 499, in _flatten
    catalog = self.trailer["/Root"].getObject()
  File "/var/lib/python-support/python2.6/pyPdf/generic.py", line 466, in __getitem__
    return dict.__getitem__(self, key).getObject()
  File "/var/lib/python-support/python2.6/pyPdf/generic.py", line 165, in getObject
    return self.pdf.getObject(self).getObject()
  File "/var/lib/python-support/python2.6/pyPdf/pdf.py", line 555, in getObject
    raise Exception, "file has not been decrypted"
Exception: file has not been decrypted

Revision history for this message
logari81 (logari81) wrote :
Revision history for this message
logari81 (logari81) wrote :

I 've found out that the document is recognized from pyPdf as encrypted. I tried to decrypt it using an empty string as password and it worked. Trying to decrypt the document with any other string failed.

>>> input.getIsEncrypted()
True
>>> input.decrypt('')
1
>>> input.decrypt('dcdsfvcfd')
0

Revision history for this message
thebitguru (farhan) wrote :

I believe this is by design. i.e. you have to decrypt using empty string and if that is the same as the user password in the PDF file then you are good, otherwise, you have to request the password from the user (either user or owner).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.