diff --git a/src/core/annotation.js b/src/core/annotation.js index de7a74407..0ae082aea 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -4104,6 +4104,8 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation { } class SignatureWidgetAnnotation extends WidgetAnnotation { + _hasValueFromXFA = false; + constructor(params) { super(params); diff --git a/src/core/writer.js b/src/core/writer.js index 2a6a7f1d7..3395d1a02 100644 --- a/src/core/writer.js +++ b/src/core/writer.js @@ -224,7 +224,7 @@ function writeXFADataForAcroform(str, changes) { continue; } const { path, value } = xfa; - if (!path) { + if (!path || value === null) { continue; } const nodePath = parseXFAPath(path); diff --git a/test/pdfs/issue21582.pdf.link b/test/pdfs/issue21582.pdf.link new file mode 100644 index 000000000..f64bfdfcc --- /dev/null +++ b/test/pdfs/issue21582.pdf.link @@ -0,0 +1 @@ +https://github.com/user-attachments/files/30091865/VBA-21-0966-ARE.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index c60a97fdf..361187d51 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -39,6 +39,14 @@ "link": true, "type": "other" }, + { + "id": "issue21582", + "file": "pdfs/issue21582.pdf", + "md5": "bcc5a2ae3a588f360edbf94c3dd476a8", + "rounds": 1, + "link": true, + "type": "other" + }, { "id": "filled-background-range", "file": "pdfs/filled-background.pdf", diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 683646425..5ac9ec8f9 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -2805,6 +2805,16 @@ describe("api", function () { await Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]); }); + it("saving should ignore Annotations with null `fieldValue` (issue 21582)", async function () { + const loadingTask = getDocument(buildGetDocumentParams("issue21582.pdf")); + const pdfDoc = await loadingTask.promise; + + const data = await pdfDoc.saveDocument(); + expect(data).toBeInstanceOf(Uint8Array); + + await loadingTask.destroy(); + }); + it("write a value in an annotation, save the pdf and load it", async function () { let loadingTask = getDocument(buildGetDocumentParams("evaljs.pdf")); let pdfDoc = await loadingTask.promise;