diff --git a/src/display/xfa_layer.js b/src/display/xfa_layer.js index 57504beb4..0292e4edb 100644 --- a/src/display/xfa_layer.js +++ b/src/display/xfa_layer.js @@ -33,7 +33,7 @@ class XfaLayer { element.attributes.type === "radio" || element.attributes.type === "checkbox" ) { - if (storedData.value === element.attributes.exportedValue) { + if (storedData.value === element.attributes.xfaOn) { html.setAttribute("checked", true); } if (intent === "print") { @@ -82,6 +82,9 @@ class XfaLayer { attributes.name = `${attributes.name}-${intent}`; } for (const [key, value] of Object.entries(attributes)) { + // We don't need to add dataId in the html object but it can + // be useful to know its value when writing printing tests: + // in this case, don't skip dataId to have its value. if (value === null || value === undefined || key === "dataId") { continue; } diff --git a/test/driver.js b/test/driver.js index 26e0d48da..22a3503ee 100644 --- a/test/driver.js +++ b/test/driver.js @@ -288,7 +288,14 @@ var rasterizeXfaLayer = (function rasterizeXfaLayerClosure() { } // eslint-disable-next-line no-shadow - function rasterizeXfaLayer(ctx, viewport, xfa, fontRules) { + function rasterizeXfaLayer( + ctx, + viewport, + xfa, + fontRules, + annotationStorage, + isPrint + ) { return new Promise(function (resolve, reject) { // Building SVG with size of the viewport. const svg = document.createElementNS(SVG_NS, "svg:svg"); @@ -316,6 +323,8 @@ var rasterizeXfaLayer = (function rasterizeXfaLayerClosure() { xfa, div, viewport: viewport.clone({ dontFlip: true }), + annotationStorage, + intent: isPrint ? "print" : "display", }); // Some unsupported type of images (e.g. tiff) @@ -631,6 +640,14 @@ var Driver = (function DriverClosure() { renderPrint = false, renderXfa = false; + if (task.annotationStorage) { + const entries = Object.entries(task.annotationStorage), + docAnnotationStorage = task.pdfDoc.annotationStorage; + for (const [key, value] of entries) { + docAnnotationStorage.setValue(key, value); + } + } + var textLayerCanvas, annotationLayerCanvas; var initPromise; if (task.type === "text") { @@ -713,7 +730,9 @@ var Driver = (function DriverClosure() { annotationLayerContext, viewport, xfa, - task.fontRules + task.fontRules, + task.pdfDoc.annotationStorage, + task.renderPrint ); }); } @@ -731,11 +750,6 @@ var Driver = (function DriverClosure() { }; if (renderPrint) { if (task.annotationStorage) { - const entries = Object.entries(task.annotationStorage), - docAnnotationStorage = task.pdfDoc.annotationStorage; - for (const [key, value] of entries) { - docAnnotationStorage.setValue(key, value); - } renderContext.includeAnnotationStorage = true; } renderContext.intent = "print"; diff --git a/test/pdfs/xfa_bug1720182.pdf.link b/test/pdfs/xfa_bug1720182.pdf.link new file mode 100644 index 000000000..c5854fa7f --- /dev/null +++ b/test/pdfs/xfa_bug1720182.pdf.link @@ -0,0 +1 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=9230780 diff --git a/test/test_manifest.json b/test/test_manifest.json index 812a5a0d9..76fbbf677 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -952,6 +952,26 @@ "enableXfa": true, "type": "eq" }, + { "id": "xfa_bug1720182", + "file": "pdfs/xfa_bug1720182.pdf", + "md5": "1351f816f0509fe750ca61ef2bd40872", + "link": true, + "rounds": 1, + "enableXfa": true, + "type": "eq", + "print": true, + "annotationStorage": { + "RadioButtonList2707": { + "value": "1" + }, + "ComplainantFirstname2710": { + "value": "Foo" + }, + "ComplainantLastname2711": { + "value": "Bar" + } + } + }, { "id": "xfa_bug1718740", "file": "pdfs/xfa_bug1718740.pdf", "md5": "fab4277f2c70fd1edb35f597f5fe6819",