Merge pull request #19289 from Snuffleupagus/issue-19281
Skip LinkAnnotations when collecting field objects (issue 19281)
This commit is contained in:
commit
4d4e1befeb
@ -20,6 +20,7 @@ import {
|
|||||||
info,
|
info,
|
||||||
InvalidPDFException,
|
InvalidPDFException,
|
||||||
isArrayEqual,
|
isArrayEqual,
|
||||||
|
objectSize,
|
||||||
PageActionEventType,
|
PageActionEventType,
|
||||||
RenderingIntentFlag,
|
RenderingIntentFlag,
|
||||||
shadow,
|
shadow,
|
||||||
@ -1773,6 +1774,13 @@ class PDFDocument {
|
|||||||
if (!(field instanceof Dict)) {
|
if (!(field instanceof Dict)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let subtype = await field.getAsync("Subtype");
|
||||||
|
subtype = subtype instanceof Name ? subtype.name : null;
|
||||||
|
// Skip unrelated annotation types (see issue 19281).
|
||||||
|
switch (subtype) {
|
||||||
|
case "Link":
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (field.has("T")) {
|
if (field.has("T")) {
|
||||||
const partName = stringToPDFString(await field.getAsync("T"));
|
const partName = stringToPDFString(await field.getAsync("T"));
|
||||||
name = name === "" ? partName : `${name}.${partName}`;
|
name = name === "" ? partName : `${name}.${partName}`;
|
||||||
@ -1888,9 +1896,12 @@ class PDFDocument {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(allPromises);
|
await Promise.all(allPromises);
|
||||||
return { allFields, orphanFields };
|
|
||||||
|
return {
|
||||||
|
allFields: objectSize(allFields) > 0 ? allFields : null,
|
||||||
|
orphanFields,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return shadow(this, "fieldObjects", promise);
|
return shadow(this, "fieldObjects", promise);
|
||||||
@ -1913,7 +1924,7 @@ class PDFDocument {
|
|||||||
if (catalogJsActions) {
|
if (catalogJsActions) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (fieldObjects) {
|
if (fieldObjects?.allFields) {
|
||||||
return Object.values(fieldObjects.allFields).some(fieldObject =>
|
return Object.values(fieldObjects.allFields).some(fieldObject =>
|
||||||
fieldObject.some(object => object.actions !== null)
|
fieldObject.some(object => object.actions !== null)
|
||||||
);
|
);
|
||||||
|
|||||||
1
test/pdfs/issue19281.pdf.link
Normal file
1
test/pdfs/issue19281.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/user-attachments/files/18304780/Antarctica-Grid.pdf
|
||||||
@ -11239,5 +11239,13 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"disableFontFace": true,
|
"disableFontFace": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue19281",
|
||||||
|
"file": "pdfs/issue19281.pdf",
|
||||||
|
"md5": "c5db558965e4189cc6db2720cdaa3e55",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "other"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1713,6 +1713,20 @@ describe("api", function () {
|
|||||||
await loadingTask.destroy();
|
await loadingTask.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("gets fieldObjects and skipping LinkAnnotations", async function () {
|
||||||
|
if (isNodeJS) {
|
||||||
|
pending("Linked test-cases are not supported in Node.js.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadingTask = getDocument(buildGetDocumentParams("issue19281.pdf"));
|
||||||
|
const pdfDoc = await loadingTask.promise;
|
||||||
|
const fieldObjects = await pdfDoc.getFieldObjects();
|
||||||
|
|
||||||
|
expect(fieldObjects).toEqual(null);
|
||||||
|
|
||||||
|
await loadingTask.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
it("gets non-existent calculationOrder", async function () {
|
it("gets non-existent calculationOrder", async function () {
|
||||||
const calculationOrder = await pdfDocument.getCalculationOrderIds();
|
const calculationOrder = await pdfDocument.getCalculationOrderIds();
|
||||||
expect(calculationOrder).toEqual(null);
|
expect(calculationOrder).toEqual(null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user