Starting with 1.27.10 PyPDF2.PdfFileReader(file_object, strict=False) will cause a trace like:
.venv/lib/python3.7/site-packages/PyPDF2/_reader.py:239: in __init__
self.read(stream)
.venv/lib/python3.7/site-packages/PyPDF2/_reader.py:965: in read
self._rebuild_xref_table(stream)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _rebuild_xref_table(self, stream):
...
# code below duplicated
readNonWhitespace(stream)
stream.seek(-1, 1)
new_trailer = readObject(stream, self)
> for key, value in list(new_trailer.items()):
E AttributeError: 'FloatObject' object has no attribute 'items'
when reading PDFs (attached below) with xref trailer issues which require rebuilding. And this reading worked like a charm before! (1.27.9 and lower)
Environment
Replicated it on Linux and Mac.
Code
mypdf.py
import PyPDF2
with open("vero.pdf", "rb") as file_object:
print(PyPDF2.PdfFileReader(file_object, strict=False).getNumPages())
% python mypdf.py
PdfReadWarning: incorrect startxref pointer(4) [_reader.py:938]
Traceback (most recent call last):
File "/Users/cmin/Repos/rpaframework/packages/pdf/mypdf.py", line 4, in <module>
print(PyPDF2.PdfFileReader(file_object, strict=False).getNumPages())
File "/Users/cmin/Repos/rpaframework/packages/pdf/.venv/lib/python3.9/site-packages/PyPDF2/_reader.py", line 239, in __init__
self.read(stream)
File "/Users/cmin/Repos/rpaframework/packages/pdf/.venv/lib/python3.9/site-packages/PyPDF2/_reader.py", line 963, in read
self._rebuild_xref_table(stream)
File "/Users/cmin/Repos/rpaframework/packages/pdf/.venv/lib/python3.9/site-packages/PyPDF2/_reader.py", line 1199, in _rebuild_xref_table
for key, value in list(new_trailer.items()):
AttributeError: 'FloatObject' object has no attribute 'items'
PDF
vero.pdf
Starting with 1.27.10
PyPDF2.PdfFileReader(file_object, strict=False)will cause a trace like:when reading PDFs (attached below) with xref trailer issues which require rebuilding. And this reading worked like a charm before! (1.27.9 and lower)
Environment
Replicated it on Linux and Mac.
Code
mypdf.py
PDF
vero.pdf