mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Skip LinkAnnotations when collecting field objects (issue 19281)
The `/Root/AcroForm/Fields` array contains a "ridiculous" number of LinkAnnotations, which obviously makes no sense since those are not form fields. To improve performance we'll thus ignore those when collecting the field objects.
This commit is contained in:
parent
5905eb1253
commit
6f062abb76
4 changed files with 37 additions and 3 deletions
|
@ -20,6 +20,7 @@ import {
|
|||
info,
|
||||
InvalidPDFException,
|
||||
isArrayEqual,
|
||||
objectSize,
|
||||
PageActionEventType,
|
||||
RenderingIntentFlag,
|
||||
shadow,
|
||||
|
@ -1775,6 +1776,13 @@ class PDFDocument {
|
|||
if (!(field instanceof Dict)) {
|
||||
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")) {
|
||||
const partName = stringToPDFString(await field.getAsync("T"));
|
||||
name = name === "" ? partName : `${name}.${partName}`;
|
||||
|
@ -1890,9 +1898,12 @@ class PDFDocument {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(allPromises);
|
||||
return { allFields, orphanFields };
|
||||
|
||||
return {
|
||||
allFields: objectSize(allFields) > 0 ? allFields : null,
|
||||
orphanFields,
|
||||
};
|
||||
});
|
||||
|
||||
return shadow(this, "fieldObjects", promise);
|
||||
|
@ -1915,7 +1926,7 @@ class PDFDocument {
|
|||
if (catalogJsActions) {
|
||||
return true;
|
||||
}
|
||||
if (fieldObjects) {
|
||||
if (fieldObjects?.allFields) {
|
||||
return Object.values(fieldObjects.allFields).some(fieldObject =>
|
||||
fieldObject.some(object => object.actions !== null)
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue