From 3ce71d0b48a91512d89bf693191a82625931dbef Mon Sep 17 00:00:00 2001 From: Maxime Lorant Date: Sat, 22 Mar 2025 10:55:49 +0100 Subject: [PATCH] ROB: ignore annotation with Go-To action missing a /D name attribute (#3211) --- pypdf/_writer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pypdf/_writer.py b/pypdf/_writer.py index 63d9fc3d7..315f92f7f 100644 --- a/pypdf/_writer.py +++ b/pypdf/_writer.py @@ -2968,7 +2968,10 @@ def _insert_filtered_annotations( anc[NameObject("/Dest")] = ArrayObject([p] + d[1:]) outlist.append(self._add_object(anc)) else: - d = cast("DictionaryObject", ano["/A"])["/D"] + annot_obj = cast("DictionaryObject", ano["/A"]) + if "/D" not in annot_obj: + continue + d = annot_obj["/D"] if isinstance(d, NullObject): continue if isinstance(d, str):