-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
is-robustness-issueFrom a users perspective, this is about robustnessFrom a users perspective, this is about robustness
Description
KeyError: '/D' when writing pdf
Environment
Which environment were you using when you encountered the problem?
$ python -m platform
Linux-5.15.0-91-generic-x86_64-with-glibc2.35
$ python -c "import pypdf;print(pypdf._debug_versions)"
pypdf==5.9.0, crypt_provider=('cryptography', '45.0.6'), PIL=11.3.0
Share here the PDF file(s) that cause the issue. The smaller they are, the
better. Let us know if we may add them to our tests!
Traceback
This is the complete traceback I see:
File "/root/miniconda3/envs/document_parse_service/lib/python3.10/site-packages/pypdf/_writer.py", line 533, in _add_page
self._unresolved_links.extend(extract_links(page, page_org))
│ │ │ │ │ └ {'/Annots': [IndirectObject(87, 0, 140100504957088), IndirectObject(89, 0, 140100504957088), IndirectObject(91, 0, 1401005049...
│ │ │ │ └ {'/Annots': [IndirectObject(88, 0, 140100503935184), IndirectObject(90, 0, 140100503935184), IndirectObject(92, 0, 1401005039...
│ │ │ └ <function extract_links at 0x7f6c3fa7fd90>
│ │ └ <method 'extend' of 'list' objects>
│ └ []
└ <pypdf._writer.PdfWriter object at 0x7f6bb0c518d0>
File "/root/miniconda3/envs/document_parse_service/lib/python3.10/site-packages/pypdf/generic/_link.py", line 82, in extract_links
new_links = [_build_link(link, new_page) for link in new_page.get("/Annots", [])]
│ │ │ └ <method 'get' of 'dict' objects>
│ │ └ {'/Annots': [IndirectObject(88, 0, 140100503935184), IndirectObject(90, 0, 140100503935184), IndirectObject(92, 0, 1401005039...
│ └ {'/Annots': [IndirectObject(88, 0, 140100503935184), IndirectObject(90, 0, 140100503935184), IndirectObject(92, 0, 1401005039...
└ <function _build_link at 0x7f6c3faae0e0>
File "/root/miniconda3/envs/document_parse_service/lib/python3.10/site-packages/pypdf/generic/_link.py", line 82, in <listcomp>
new_links = [_build_link(link, new_page) for link in new_page.get("/Annots", [])]
│ │ │ │ │ └ <method 'get' of 'dict' objects>
│ │ │ │ └ {'/Annots': [IndirectObject(88, 0, 140100503935184), IndirectObject(90, 0, 140100503935184), IndirectObject(92, 0, 1401005039...
│ │ │ └ IndirectObject(88, 0, 140100503935184)
│ │ └ {'/Annots': [IndirectObject(88, 0, 140100503935184), IndirectObject(90, 0, 140100503935184), IndirectObject(92, 0, 1401005039...
│ └ IndirectObject(88, 0, 140100503935184)
└ <function _build_link at 0x7f6c3faae0e0>
File "/root/miniconda3/envs/document_parse_service/lib/python3.10/site-packages/pypdf/generic/_link.py", line 103, in _build_link
return _create_link(action["/D"], src)
│ │ └ None
│ └ {'/S': '/GoTo'}
└ <function _create_link at 0x7f6c3faae170>
File "/root/miniconda3/envs/document_parse_service/lib/python3.10/site-packages/pypdf/generic/_data_structures.py", line 477, in __getitem__
return dict.__getitem__(self, key).get_object()
│ └ '/D'
└ {'/S': '/GoTo'}
Metadata
Metadata
Assignees
Labels
is-robustness-issueFrom a users perspective, this is about robustnessFrom a users perspective, this is about robustness