From b531720d9c3a07474e96c925c77bba5f5e3bc5a4 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 3 May 2025 11:14:01 +0200 Subject: [PATCH] Simplify the `serializeXfaData` method and related code Rather than having a dedicated `BasePdfManager`-method for this one call-site we can instead change `PDFDocument.prototype.serializeXfaData` to a non-async method, that we invoke via `BasePdfManager.prototype.ensureDoc`. --- src/core/document.js | 2 +- src/core/pdf_manager.js | 4 ---- src/core/worker.js | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index d777d0ab9..e6202294d 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1408,7 +1408,7 @@ class PDFDocument { this.xfaFactory.appendFonts(pdfFonts, reallyMissingFonts); } - async serializeXfaData(annotationStorage) { + serializeXfaData(annotationStorage) { return this.xfaFactory ? this.xfaFactory.serializeData(annotationStorage) : null; diff --git a/src/core/pdf_manager.js b/src/core/pdf_manager.js index 8b13dfbff..55d4aaec9 100644 --- a/src/core/pdf_manager.js +++ b/src/core/pdf_manager.js @@ -127,10 +127,6 @@ class BasePdfManager { return this.pdfDocument.loadXfaImages(); } - serializeXfaData(annotationStorage) { - return this.pdfDocument.serializeXfaData(annotationStorage); - } - cleanup(manuallyTriggered = false) { return this.pdfDocument.cleanup(manuallyTriggered); } diff --git a/src/core/worker.js b/src/core/worker.js index eb51bacfa..66fa9ae15 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -617,7 +617,9 @@ class WorkerMessageHandler { } if (isPureXfa) { - promises.push(pdfManager.serializeXfaData(annotationStorage)); + promises.push( + pdfManager.ensureDoc("serializeXfaData", [annotationStorage]) + ); } else { for (let pageIndex = 0; pageIndex < numPages; pageIndex++) { promises.push(