Hello,
we found 2 bugs in the library.
This line crashes when there is no /Rotation information in the pdf.
|
rotation = get_rotation(inheritable.Rotate) |
And also this line crashes:
|
mbox, bbox = getrects(inheritable, viewinfo, rotation) |
I added try catch and set default but this is just a temporary fix. Especially the defaults for the mbox are totally wrong when the pdf is horizontal oriented.
The company was so kind and generated a sharable pdf which contains the problem.
minimal example:
from io import BytesIO
from pdfrw import PageMerge
from pdfrw import PdfReader
in_file = open("Warenbewegungsschein_Test.pdf", "rb") # opening for [r]eading as [b]inary
data = in_file.read()
raw_pdf = BytesIO(data)
raw_pdf.seek(0)
srcpage = PdfReader(raw_pdf).pages
srcpage = PageMerge() + srcpage[0]
(line numbers may be not correct because of debugging)
python simple_test.py
Traceback (most recent call last):
File "/home/manuel/dls-pdf-parser/pdf_merger/simple_test.py", line 17, in <module>
srcpage = PageMerge() + srcpage[0]
File "/home/manuel/dls-pdf-parser/venv/lib/python3.10/site-packages/pdfrw/pagemerge.py", line 169, in __add__
self.add(item)
File "/home/manuel/dls-pdf-parser/venv/lib/python3.10/site-packages/pdfrw/pagemerge.py", line 176, in add
obj = RectXObj(obj)
File "/home/manuel/dls-pdf-parser/venv/lib/python3.10/site-packages/pdfrw/pagemerge.py", line 56, in __init__
base = pagexobj(page, viewinfo)
File "/home/manuel/dls-pdf-parser/venv/lib/python3.10/site-packages/pdfrw/buildxobj.py", line 300, in pagexobj
rotate = inheritable.Rotate
File "/home/manuel/dls-pdf-parser/venv/lib/python3.10/site-packages/pdfrw/objects/pdfdict.py", line 19, in __getattr__
return self[PdfName(name)]
File "/home/manuel/dls-pdf-parser/venv/lib/python3.10/site-packages/pdfrw/objects/pdfdict.py", line 25, in __getitem__
value = mydict[name]
TypeError: string indices must be integers
Warenbewegungsschein_Test.pdf
Hello,
we found 2 bugs in the library.
This line crashes when there is no
/Rotationinformation in the pdf.pdfrw/pdfrw/buildxobj.py
Line 294 in a9d498d
And also this line crashes:
pdfrw/pdfrw/buildxobj.py
Line 295 in a9d498d
I added try catch and set default but this is just a temporary fix. Especially the defaults for the mbox are totally wrong when the pdf is horizontal oriented.
The company was so kind and generated a sharable pdf which contains the problem.
minimal example:
(line numbers may be not correct because of debugging)
Warenbewegungsschein_Test.pdf