From ff62fc8e2c7b805f5ce6ee36828b08cf85cb277a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 8 Nov 2023 10:52:56 +0100 Subject: [PATCH] Skip `fieldObjects` that are not actually References The `fieldObjects`-getter is implemented in the `PDFDocument` class, which means that the `this._localIdFactory`-property that we pass to `AnnotationFactory.create` doesn't actually exist. The reason that this hasn't caused any bugs, that I'm aware of, is that all /Fields-entries need to be References to actually make sense. --- src/core/document.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index c56378243..a7b1342ef 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1714,7 +1714,10 @@ class PDFDocument { async #collectFieldObjects(name, fieldRef, promises, annotationGlobals) { const { xref } = this; - const field = await xref.fetchIfRefAsync(fieldRef); + if (!(fieldRef instanceof Ref)) { + return; + } + const field = await xref.fetchAsync(fieldRef); if (!(field instanceof Dict)) { return; } @@ -1731,7 +1734,7 @@ class PDFDocument { xref, fieldRef, annotationGlobals, - this._localIdFactory, + /* idFactory = */ null, /* collectFields */ true, /* pageRef */ null )