Merge pull request #19903 from Snuffleupagus/shorten-fieldObjects-getter

Shorten the `PDFDocument.prototype.fieldObjects` getter slightly
This commit is contained in:
calixteman 2025-05-09 15:49:51 +02:00 committed by GitHub
commit 293506ada7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1823,20 +1823,17 @@ class PDFDocument {
if (!formInfo.hasFields) {
return null;
}
const [annotationGlobals, acroForm] = await Promise.all([
this.pdfManager.ensureDoc("annotationGlobals"),
this.pdfManager.ensureCatalog("acroForm"),
]);
const annotationGlobals = await this.annotationGlobals;
if (!annotationGlobals) {
return null;
}
const { acroForm } = annotationGlobals;
const visitedRefs = new RefSet();
const allFields = Object.create(null);
const fieldPromises = new Map();
const orphanFields = new RefSetCache();
for (const fieldRef of await acroForm.getAsync("Fields")) {
for (const fieldRef of acroForm.get("Fields")) {
await this.#collectFieldObjects(
"",
null,