mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 16:37:22 +02:00
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:
parent
5266f13ea4
commit
ee56dc7719
@ -4104,6 +4104,8 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SignatureWidgetAnnotation extends WidgetAnnotation {
|
class SignatureWidgetAnnotation extends WidgetAnnotation {
|
||||||
|
_hasValueFromXFA = false;
|
||||||
|
|
||||||
constructor(params) {
|
constructor(params) {
|
||||||
super(params);
|
super(params);
|
||||||
|
|
||||||
|
|||||||
@ -224,7 +224,7 @@ function writeXFADataForAcroform(str, changes) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const { path, value } = xfa;
|
const { path, value } = xfa;
|
||||||
if (!path) {
|
if (!path || value === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const nodePath = parseXFAPath(path);
|
const nodePath = parseXFAPath(path);
|
||||||
|
|||||||
1
test/pdfs/issue21582.pdf.link
Normal file
1
test/pdfs/issue21582.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/user-attachments/files/30091865/VBA-21-0966-ARE.pdf
|
||||||
@ -39,6 +39,14 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"type": "other"
|
"type": "other"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "issue21582",
|
||||||
|
"file": "pdfs/issue21582.pdf",
|
||||||
|
"md5": "bcc5a2ae3a588f360edbf94c3dd476a8",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "other"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "filled-background-range",
|
"id": "filled-background-range",
|
||||||
"file": "pdfs/filled-background.pdf",
|
"file": "pdfs/filled-background.pdf",
|
||||||
|
|||||||
@ -2805,6 +2805,16 @@ describe("api", function () {
|
|||||||
await Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]);
|
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 () {
|
it("write a value in an annotation, save the pdf and load it", async function () {
|
||||||
let loadingTask = getDocument(buildGetDocumentParams("evaljs.pdf"));
|
let loadingTask = getDocument(buildGetDocumentParams("evaljs.pdf"));
|
||||||
let pdfDoc = await loadingTask.promise;
|
let pdfDoc = await loadingTask.promise;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user