mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 08:27:19 +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 {
|
||||
_hasValueFromXFA = false;
|
||||
|
||||
constructor(params) {
|
||||
super(params);
|
||||
|
||||
|
||||
@ -224,7 +224,7 @@ function writeXFADataForAcroform(str, changes) {
|
||||
continue;
|
||||
}
|
||||
const { path, value } = xfa;
|
||||
if (!path) {
|
||||
if (!path || value === null) {
|
||||
continue;
|
||||
}
|
||||
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,
|
||||
"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",
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user