Skip to content

Python 3: TypeError: ord() expected string of length 1, but int found #605

@demongolem

Description

@demongolem

#57 This was closed, but not fixed completely as I believe this is a different code path that causes the same problem. There was another commenter after it was closed that said they still have that problem. I too have that problem. It occurs with a handful of pdf files, not all of them. Nonetheless, I have entire pdf files where all the pages spit out this same type error

Traceback (most recent call last):
  File "eclipse-workspace/AccidentReports/FetchFromATSB.py", line 66, in process_file
    text += pageObj.extractText()
  File "/.local/lib/python3.6/site-packages/PyPDF2/pdf.py", line 2595, in extractText
    content = ContentStream(content, self.pdf)
  File "/.local/lib/python3.6/site-packages/PyPDF2/pdf.py", line 2673, in __init__
    stream = BytesIO(b_(stream.getData()))
  File "/.local/lib/python3.6/site-packages/PyPDF2/generic.py", line 841, in getData
    decoded._data = filters.decodeStreamData(self)
  File "/.local/lib/python3.6/site-packages/PyPDF2/filters.py", line 350, in decodeStreamData
    data = LZWDecode.decode(data, stream.get("/DecodeParms"))
  File "/.local/lib/python3.6/site-packages/PyPDF2/filters.py", line 255, in decode
    return LZWDecode.decoder(data).decode()
  File "/.local/lib/python3.6/site-packages/PyPDF2/filters.py", line 228, in decode
    cW = self.nextCode();
  File "/.local/lib/python3.6/site-packages/PyPDF2/filters.py", line 205, in nextCode
    nextbits=ord(self.data[self.bytepos])
TypeError: ord() expected string of length 1, but int found

Metadata

Metadata

Assignees

No one assigned

    Labels

    is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDF

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions