from PyPDF3 import PdfFileMerger
pdf_merger = PdfFileMerger()
pdfs_to_merge = ['E:\\modules\\pdfMerger\\10 - example_page.pdf']
for f in pdfs_to_merge:
pdf_merger.append(f)
Traceback:
Traceback (most recent call last):
File "E:/modules/pdfMerger/minimal_example.py", line 7, in <module>
pdf_merger.append(f)
File "E:\modules\venv\v3\lib\site-packages\PyPDF3\merger.py", line 203, in append
self.merge(len(self.pages), fileobj, bookmark, pages, import_bookmarks)
File "E:\modules\venv\v3\lib\site-packages\PyPDF3\merger.py", line 151, in merge
outline = pdfr.getOutlines()
File "E:\modules\venv\v3\lib\site-packages\PyPDF3\pdf.py", line 1481, in getOutlines
outline = self._buildOutline(node)
File "E:\modules\venv\v3\lib\site-packages\PyPDF3\pdf.py", line 1563, in _buildOutline
outline = self._buildDestination(title, dest)
File "E:\modules\venv\v3\lib\site-packages\PyPDF3\pdf.py", line 1544, in _buildDestination
return Destination(title, page, typ, *array)
File "E:\modules\venv\v3\lib\site-packages\PyPDF3\generic.py", line 1060, in __init__
self[NameObject("/Zoom")]) = args
ValueError: not enough values to unpack (expected 3, got 2)
The content of args is a tuple with two PyPDF3.generic.NullObjects.
Monkey-patching at line 1058 to
# from table 8.2 of the PDF 1.7 reference.
if typ == "/XYZ":
args += (args[1],) # extending args to avoid ValueError
(self[NameObject("/Left")], self[NameObject("/Top")],
self[NameObject("/Zoom")]) = args
leads to a full run, that is, my code works as expected.
Dear all,
I recently got a new scanner (Xerox 6515) and pages scanned into pdfs using the device can not be merged with other pdfs.
Minimal example (example_page.pdf):
Traceback:
The content of args is a tuple with two PyPDF3.generic.NullObjects. Monkey-patching at line 1058 to
leads to a full run, that is, my code works as expected.