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 - Default background in rectangle is white #13684

Merged
merged 1 commit into from
Jul 6, 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
2 changes: 1 addition & 1 deletion src/core/xfa/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class BehaviorOverride extends ContentObject {
this[$content]
.trim()
.split(/\s+/)
.filter(x => !!x && x.include(":"))
.filter(x => x.includes(":"))
.map(x => x.split(":", 2))
);
}
Expand Down
40 changes: 26 additions & 14 deletions src/core/xfa/html_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,40 +420,50 @@ function createWrapper(node, html) {
class: ["xfaWrapper"],
style: Object.create(null),
},
children: [html],
children: [],
};

attributes.class.push("xfaWrapped");

if (node.border) {
const { widths, insets } = node.border[$extra];
let shiftH = 0;
let shiftW = 0;
let width, height;
let top = insets[0];
let left = insets[3];
const insetsH = insets[0] + insets[2];
const insetsW = insets[1] + insets[3];
switch (node.border.hand) {
case "even":
shiftW = widths[0] / 2;
shiftH = widths[3] / 2;
top -= widths[0] / 2;
left -= widths[3] / 2;
width = `calc(100% + ${(widths[1] + widths[3]) / 2 - insetsW}px)`;
height = `calc(100% + ${(widths[0] + widths[2]) / 2 - insetsH}px)`;
break;
case "left":
shiftW = widths[0];
shiftH = widths[3];
top -= widths[0];
left -= widths[3];
width = `calc(100% + ${widths[1] + widths[3] - insetsW}px)`;
height = `calc(100% + ${widths[0] + widths[2] - insetsH}px)`;
break;
case "right":
width = insetsW ? `calc(100% - ${insetsW}px)` : "100%";
height = insetsH ? `calc(100% - ${insetsH}px)` : "100%";
break;
}
const insetsW = insets[1] + insets[3];
const insetsH = insets[0] + insets[2];
const classNames = ["xfaBorder"];
if (isPrintOnly(node.border)) {
classNames.push("xfaPrintOnly");
}

const border = {
name: "div",
attributes: {
class: classNames,
style: {
top: `${insets[0] - widths[0] + shiftW}px`,
left: `${insets[3] - widths[3] + shiftH}px`,
width: insetsW ? `calc(100% - ${insetsW}px)` : "100%",
height: insetsH ? `calc(100% - ${insetsH}px)` : "100%",
top: `${top}px`,
left: `${left}px`,
width,
height,
},
},
children: [],
Expand All @@ -471,7 +481,9 @@ function createWrapper(node, html) {
delete style[key];
}
}
wrapper.children.push(border);
wrapper.children.push(border, html);
} else {
wrapper.children.push(html);
}

for (const key of [
Expand Down
2 changes: 1 addition & 1 deletion src/core/xfa/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -2689,7 +2689,7 @@ class Fill extends XFAObject {
}
if (parent instanceof Rectangle || parent instanceof Arc) {
propName = "fill";
style.fill = "transparent";
style.fill = "white";
}

for (const name of Object.getOwnPropertyNames(this)) {
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/xfa_issue13679.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/6768253/Form_MGT-7.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,14 @@
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_issue13679",
"file": "pdfs/xfa_issue13679.pdf",
"md5": "b7231495f0c063435e7cfb92b4f281a3",
"link": true,
"rounds": 1,
"enableXfa": true,
"type": "eq"
},
{ "id": "xfa_issue13633",
"file": "pdfs/xfa_issue13633.pdf",
"md5": "e5b0d09285ca6a140eba08d740be0ea0",
Expand Down
21 changes: 0 additions & 21 deletions web/xfa_layer_builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
text-align: initial;
top: 0;
left: 0;
z-index: 200;
transform-origin: 0 0;
line-height: 1.2;
}
Expand Down Expand Up @@ -76,26 +75,6 @@
vertical-align: 0;
}

.xfaDraw {
z-index: 100;
}

.xfaExclgroup {
z-index: 200;
}

.xfaField {
z-index: 300;
}

.xfaRich {
z-index: 300;
}

.xfaSubform {
z-index: 200;
}

.xfaCaption {
overflow: hidden;
flex: 0 1 auto;
Expand Down