Ignore Annotations with fieldValue = null when saving (issue 21582)

Some Annotations, e.g. `SignatureWidgetAnnotation`, set `fieldValue = null` which may causing saving to fail during `writeXFADataForAcroform`, hence we simply ignore any such Annotation-data during saving.
This commit is contained in:
Jonas Jenwald 2026-07-17 22:18:03 +02:00
parent 5266f13ea4
commit ee56dc7719
5 changed files with 22 additions and 1 deletions

View File

@ -4104,6 +4104,8 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
}
class SignatureWidgetAnnotation extends WidgetAnnotation {
_hasValueFromXFA = false;
constructor(params) {
super(params);

View File

@ -224,7 +224,7 @@ function writeXFADataForAcroform(str, changes) {
continue;
}
const { path, value } = xfa;
if (!path) {
if (!path || value === null) {
continue;
}
const nodePath = parseXFAPath(path);

View File

@ -0,0 +1 @@
https://github.com/user-attachments/files/30091865/VBA-21-0966-ARE.pdf

View File

@ -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",

View File

@ -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;