Merge pull request #17395 from Snuffleupagus/pypdf-2332
Support Annotations with corrupt /BS-entries
This commit is contained in:
commit
988d3a188f
@ -999,6 +999,8 @@ class Annotation {
|
|||||||
}
|
}
|
||||||
if (borderStyle.has("BS")) {
|
if (borderStyle.has("BS")) {
|
||||||
const dict = borderStyle.get("BS");
|
const dict = borderStyle.get("BS");
|
||||||
|
|
||||||
|
if (dict instanceof Dict) {
|
||||||
const dictType = dict.get("Type");
|
const dictType = dict.get("Type");
|
||||||
|
|
||||||
if (!dictType || isName(dictType, "Border")) {
|
if (!dictType || isName(dictType, "Border")) {
|
||||||
@ -1006,6 +1008,7 @@ class Annotation {
|
|||||||
this.borderStyle.setStyle(dict.get("S"));
|
this.borderStyle.setStyle(dict.get("S"));
|
||||||
this.borderStyle.setDashArray(dict.getArray("D"));
|
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");
|
||||||
if (Array.isArray(array) && array.length >= 3) {
|
if (Array.isArray(array) && array.length >= 3) {
|
||||||
|
1
test/pdfs/pypdf2332.pdf.link
Normal file
1
test/pdfs/pypdf2332.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/py-pdf/pypdf/files/13606678/output.pdf
|
@ -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",
|
||||||
|
@ -35,7 +35,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
CMAP_URL,
|
CMAP_URL,
|
||||||
createIdFactory,
|
createIdFactory,
|
||||||
getNodeVersion,
|
|
||||||
STANDARD_FONT_DATA_URL,
|
STANDARD_FONT_DATA_URL,
|
||||||
XRefMock,
|
XRefMock,
|
||||||
} from "./test_utils.js";
|
} from "./test_utils.js";
|
||||||
@ -2209,10 +2208,9 @@ describe("annotation", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should compress and save text", async function () {
|
it("should compress and save text", async function () {
|
||||||
if (isNodeJS && getNodeVersion().major >= 20) {
|
if (isNodeJS) {
|
||||||
pending(
|
pending(
|
||||||
"CompressionStream behaves differently in Node.js >= 20, " +
|
"CompressionStream behaves differently in Node.js, compared to Firefox and Chrome."
|
||||||
"compared to Firefox, Chrome, and Node.js 18."
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const textWidgetRef = Ref.get(123, 0);
|
const textWidgetRef = Ref.get(123, 0);
|
||||||
|
@ -144,22 +144,11 @@ function createIdFactory(pageIndex) {
|
|||||||
return page._localIdFactory;
|
return page._localIdFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNodeVersion() {
|
|
||||||
if (!isNodeJS) {
|
|
||||||
throw new Error("getNodeVersion - only valid in Node.js environments.");
|
|
||||||
}
|
|
||||||
const [major, minor, patch] = process.versions.node
|
|
||||||
.split(".")
|
|
||||||
.map(parseFloat);
|
|
||||||
return { major, minor, patch };
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
buildGetDocumentParams,
|
buildGetDocumentParams,
|
||||||
CMAP_URL,
|
CMAP_URL,
|
||||||
createIdFactory,
|
createIdFactory,
|
||||||
DefaultFileReaderFactory,
|
DefaultFileReaderFactory,
|
||||||
getNodeVersion,
|
|
||||||
STANDARD_FONT_DATA_URL,
|
STANDARD_FONT_DATA_URL,
|
||||||
TEST_PDFS_PATH,
|
TEST_PDFS_PATH,
|
||||||
XRefMock,
|
XRefMock,
|
||||||
|
Loading…
Reference in New Issue
Block a user