-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
PdfWriterThe PdfWriter component is affectedThe PdfWriter component is affectedis-robustness-issueFrom a users perspective, this is about robustnessFrom a users perspective, this is about robustness
Description
I am using pypdf to merge PDF files. I haven't had an issue, until I hit a specific PDF file. Every other PDF file (even ones from the same "bundle" [plan set]). I just have no idea why this PDF file is having an issue with the Writer, or if there is any sort of workaround/front end adjustment I can make to the PDF file.
Environment
$ python -m platform
Windows-11-10.0.22631-SP0
$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==5.1.0, crypt_provider=('local_crypt_fallback', '0.0.0'), PIL=noneCode + PDF
This is a minimal, complete example that shows the issue:
import glob
import pypdf
fromp = '\\\\UNC\\Path\\*.pdf' #actual path exists, other PDF files merge fine
merger = pypdf.PdfWriter()
paths = glob.glob(fromp)
paths.sort()
for pdf in paths:
merger.append(pdf) #Get error here on the problem PDF fileFile link below:
C0.00 - COVER SHEET.pdf
Traceback
This is the complete traceback I see:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Users\ethanwade\AppData\Roaming\Python\Python312\site-packages\pypdf\_writer.py", line 2638, in append
self.merge(
File "C:\Users\ethanwade\AppData\Roaming\Python\Python312\site-packages\pypdf\_writer.py", line 2796, in merge
lst = self._insert_filtered_annotations(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ethanwade\AppData\Roaming\Python\Python312\site-packages\pypdf\_writer.py", line 2994, in _insert_filtered_annotations
p = self._get_cloned_page(d[0], pages, reader)
~^^^
TypeError: 'NullObject' object is not subscriptable
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
PdfWriterThe PdfWriter component is affectedThe PdfWriter component is affectedis-robustness-issueFrom a users perspective, this is about robustnessFrom a users perspective, this is about robustness