Skip to content

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

@cabrerachaparro

Description

@cabrerachaparro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions