Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XFA - Checkboxes must be printed (bug 1720182) #13743

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/display/xfa_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 21 additions & 7 deletions test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -713,7 +730,9 @@ var Driver = (function DriverClosure() {
annotationLayerContext,
viewport,
xfa,
task.fontRules
task.fontRules,
task.pdfDoc.annotationStorage,
task.renderPrint
);
});
}
Expand All @@ -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";
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/xfa_bug1720182.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://bugzilla.mozilla.org/attachment.cgi?id=9230780
20 changes: 20 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down