Support Annotations with corrupt /BS-entries

There's obviously a few things wrong with the Annotations in the referenced PDF document, however parsing of an Annotation shouldn't just break if the /BS-entry isn't a dictionary.
This commit is contained in:
Jonas Jenwald 2023-12-09 10:30:23 +01:00
parent 07aa706f1c
commit 63eb8991a3
3 changed files with 18 additions and 5 deletions

View File

@ -999,12 +999,15 @@ class Annotation {
} }
if (borderStyle.has("BS")) { if (borderStyle.has("BS")) {
const dict = borderStyle.get("BS"); const dict = borderStyle.get("BS");
const dictType = dict.get("Type");
if (!dictType || isName(dictType, "Border")) { if (dict instanceof Dict) {
this.borderStyle.setWidth(dict.get("W"), this.rectangle); const dictType = dict.get("Type");
this.borderStyle.setStyle(dict.get("S"));
this.borderStyle.setDashArray(dict.getArray("D")); if (!dictType || isName(dictType, "Border")) {
this.borderStyle.setWidth(dict.get("W"), this.rectangle);
this.borderStyle.setStyle(dict.get("S"));
this.borderStyle.setDashArray(dict.getArray("D"));
}
} }
} else if (borderStyle.has("Border")) { } else if (borderStyle.has("Border")) {
const array = borderStyle.getArray("Border"); const array = borderStyle.getArray("Border");

View File

@ -0,0 +1 @@
https://github.com/py-pdf/pypdf/files/13606678/output.pdf

View File

@ -4902,6 +4902,15 @@
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "pypdf2332",
"file": "pdfs/pypdf2332.pdf",
"md5": "883d2cf4d0ed16e32c917498fe9843dd",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq",
"annotations": true
},
{ "id": "issue6151", { "id": "issue6151",
"file": "pdfs/issue6151.pdf", "file": "pdfs/issue6151.pdf",
"md5": "926f8c6b25e6f0978759f7947d70e079", "md5": "926f8c6b25e6f0978759f7947d70e079",