Prevent issues, in PDFDocument.fieldObjects
, for invalid Annotations
For an invalid Annotation, there's one code-path where `undefined` is returned from `AnnotationFactory._create`. That'd currently, incorrectly, trigger an error during the `PDFDocument._collectFieldObjects` parsing which thus seem good to avoid. Along these lines, the filtering in `PDFDocument.fieldObjects` is also updated to handle both `null` and `undefined` the same way.
This commit is contained in:
parent
e389ed6201
commit
b44a975d7c
@ -969,7 +969,7 @@ class PDFDocument {
|
|||||||
this.pdfManager,
|
this.pdfManager,
|
||||||
this._localIdFactory
|
this._localIdFactory
|
||||||
)
|
)
|
||||||
.then(annotation => annotation.getFieldObject())
|
.then(annotation => annotation && annotation.getFieldObject())
|
||||||
.catch(function (reason) {
|
.catch(function (reason) {
|
||||||
warn(`_collectFieldObjects: "${reason}".`);
|
warn(`_collectFieldObjects: "${reason}".`);
|
||||||
return null;
|
return null;
|
||||||
@ -999,7 +999,7 @@ class PDFDocument {
|
|||||||
for (const [name, promises] of fieldPromises) {
|
for (const [name, promises] of fieldPromises) {
|
||||||
allPromises.push(
|
allPromises.push(
|
||||||
Promise.all(promises).then(fields => {
|
Promise.all(promises).then(fields => {
|
||||||
fields = fields.filter(field => field !== null);
|
fields = fields.filter(field => !!field);
|
||||||
if (fields.length > 0) {
|
if (fields.length > 0) {
|
||||||
allFields[name] = fields;
|
allFields[name] = fields;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user