cycomanic / Menextract2pdf

Extract Mendely annotations to PDF FIles
GNU General Public License v3.0
35 stars 15 forks source link

zlib.error: Error -5 while decompressing data: incomplete or truncated stream #24

Open cabrerachaparro opened 4 years ago

cabrerachaparro commented 4 years ago

Hello, I am having the following error when trying to open a PDF file. I think the issue is because the pdf file is editable. It worked using a non editable file.

Code existing_pdf = PdfFileReader(open("S21.pdf","rb"))

Error

Traceback (most recent call last):
  File "fill.py", line 16, in <module>
    existing_pdf = PdfFileReader(open("S21.pdf","rb"))
  File "/home/dcabrera/.local/lib/python3.8/site-packages/PyPDF2/pdf.py", line 1084, in __init__
    self.read(stream)
  File "/home/dcabrera/.local/lib/python3.8/site-packages/PyPDF2/pdf.py", line 1807, in read
    streamData = BytesIO(b_(xrefstream.getData()))
  File "/home/dcabrera/.local/lib/python3.8/site-packages/PyPDF2/generic.py", line 841, in getData
    decoded._data = filters.decodeStreamData(self)
  File "/home/dcabrera/.local/lib/python3.8/site-packages/PyPDF2/filters.py", line 346, in decodeStreamData
    data = FlateDecode.decode(data, stream.get("/DecodeParms"))
  File "/home/dcabrera/.local/lib/python3.8/site-packages/PyPDF2/filters.py", line 111, in decode
    data = decompress(data)
  File "/home/dcabrera/.local/lib/python3.8/site-packages/PyPDF2/filters.py", line 49, in decompress
    return zlib.decompress(data)
zlib.error: Error -5 while decompressing data: incomplete or truncated stream