Skip to content

TypeError: '<' not supported between instances of 'int' and 'NameObject' #2013

@james811223ad

Description

@james811223ad

I tried calling PdfReader on a pdf, but got the error.

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
Linux-4.14.314-164.539.amzn1.x86_64-x86_64-with-glibc2.17

$ python -c "import pypdf;print(pypdf.__version__)"
3.13.0

Traceback

This is the complete Traceback I see:

entry 5928 in Xref table invalid but object found

TypeError Traceback (most recent call last)
Cell In[36], line 1
----> 1 PdfReader('temp/t.pdf')

File ~/SageMaker/custom-miniconda/miniconda/envs/py311/lib/python3.11/site-packages/pypdf/_reader.py:326, in PdfReader.init(self, stream, strict, password)
324 with open(stream, "rb") as fh:
325 stream = BytesIO(fh.read())
--> 326 self.read(stream)
327 self.stream = stream
329 self._override_encryption = False

File ~/SageMaker/custom-miniconda/miniconda/envs/py311/lib/python3.11/site-packages/pypdf/_reader.py:1548, in PdfReader.read(self, stream)
1545 logger_warning(f"incorrect startxref pointer({xref_issue_nr})", name)
1547 # read all cross reference tables and their trailers
-> 1548 self._read_xref_tables_and_trailers(stream, startxref, xref_issue_nr)
1550 # if not zero-indexed, verify that the table is correct; change it if necessary
1551 if self.xref_index and not self.strict:

File ~/SageMaker/custom-miniconda/miniconda/envs/py311/lib/python3.11/site-packages/pypdf/_reader.py:1758, in PdfReader._read_xref_tables_and_trailers(self, stream, startxref, xref_issue_nr)
1756 x = stream.read(1)
1757 if x == b"x":
-> 1758 startxref = self._read_xref(stream)
1759 elif xref_issue_nr:
1760 try:

File ~/SageMaker/custom-miniconda/miniconda/envs/py311/lib/python3.11/site-packages/pypdf/_reader.py:1794, in PdfReader._read_xref(self, stream)
1793 def _read_xref(self, stream: StreamType) -> Optional[int]:
-> 1794 self._read_standard_xref_table(stream)
1795 read_non_whitespace(stream)
1796 stream.seek(-1, 1)

File ~/SageMaker/custom-miniconda/miniconda/envs/py311/lib/python3.11/site-packages/pypdf/_reader.py:1661, in PdfReader._read_standard_xref_table(self, stream)
1659 stream.seek(-1, 1)
1660 cnt = 0
-> 1661 while cnt < size:
1662 line = stream.read(20)
1664 # It's very clear in section 3.4.3 of the PDF spec
1665 # that all cross-reference table lines are a fixed
1666 # 20 bytes (as of PDF 1.7). However, some files have
1667 # 21-byte entries (or more) due to the use of \r\n
1668 # (CRLF) EOL's. Detect that case, and adjust the line
1669 # until it does not begin with a \r (CR) or \n (LF).

TypeError: '<' not supported between instances of 'int' and 'NameObject'

Note

I can't share the pdf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions