diff --git a/src/core/xfa/layout.js b/src/core/xfa/layout.js
index ad12c70dcb25af..5ff96b07550c8f 100644
--- a/src/core/xfa/layout.js
+++ b/src/core/xfa/layout.js
@@ -266,7 +266,7 @@ function checkDimensions(node, space) {
}
const parent = node[$getParent]();
- const attempt = (node[$extra] && node[$extra].attempt) || 0;
+ const attempt = (parent[$extra] && parent[$extra].attempt) || 0;
switch (parent.layout) {
case "lr-tb":
case "rl-tb":
@@ -307,20 +307,13 @@ function checkDimensions(node, space) {
}
return true;
case "position":
- const [x, y, w, h] = getTransformedBBox(node);
- const isWidthOk = node.w === "" || Math.round(w + x - space.width) <= 1;
- const isHeightOk = node.h === "" || Math.round(h + y - space.height) <= 1;
-
- if (isWidthOk && isHeightOk) {
+ const [, y, , h] = getTransformedBBox(node);
+ if (node.h === "" || Math.round(h + y - space.height) <= 1) {
return true;
}
const area = node[$getTemplateRoot]()[$extra].currentContentArea;
- if (isWidthOk) {
- return h + y > area.h;
- }
-
- return w + x > area.w;
+ return h + y > area.h;
case "rl-row":
case "row":
default:
diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js
index 0c134100d0e96d..3f089d748de270 100644
--- a/src/core/xfa/template.js
+++ b/src/core/xfa/template.js
@@ -2390,8 +2390,10 @@ class Field extends XFAObject {
const caption = this.caption ? this.caption[$toHTML]().html : null;
if (!caption) {
- // Even if no caption this class will help to center the ui.
- ui.attributes.class.push("xfaLeft");
+ if (ui.attributes.class) {
+ // Even if no caption this class will help to center the ui.
+ ui.attributes.class.push("xfaLeft");
+ }
return HTMLResult.success(createWrapper(this, html), bbox);
}
@@ -3753,7 +3755,7 @@ class Radial extends XFAObject {
this.type === "toEdge"
? `${startColor},${endColor}`
: `${endColor},${startColor}`;
- return `radial-gradient(circle to center, ${colors})`;
+ return `radial-gradient(circle at center, ${colors})`;
}
}
@@ -4269,6 +4271,7 @@ class Subform extends XFAObject {
}
if (children.length === 0) {
+ delete this[$extra];
return HTMLResult.EMPTY;
}
@@ -4540,6 +4543,7 @@ class Template extends XFAObject {
while (true) {
if (!hasSomething) {
+ mainHtml.children.pop();
// Nothing has been added in the previous page
if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
warn("XFA - Something goes wrong: please file a bug.");
diff --git a/test/pdfs/xfa_dhl_shipment.pdf.link b/test/pdfs/xfa_dhl_shipment.pdf.link
new file mode 100644
index 00000000000000..e68bd4c86065cd
--- /dev/null
+++ b/test/pdfs/xfa_dhl_shipment.pdf.link
@@ -0,0 +1 @@
+https://web.archive.org/web/20210621073147/https://www.dhl.com/content/dam/downloads/g0/express/emailship_page/globalpage/dhl_emailship_pdfclient_my_en.pdf
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 0cc3b28fe291c0..426eea6eb4bc51 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -930,6 +930,14 @@
"link": true,
"type": "load"
},
+ { "id": "xfa_dhl_shipment",
+ "file": "pdfs/xfa_dhl_shipment.pdf",
+ "md5": "503ece429d69e7d626d6932a475fbe63",
+ "link": true,
+ "rounds": 1,
+ "enableXfa": true,
+ "type": "eq"
+ },
{ "id": "xfa_bug1716047",
"file": "pdfs/xfa_bug1716047.pdf",
"md5": "2f524163bd8397f43d195090978c3b56",
diff --git a/test/unit/xfa_tohtml_spec.js b/test/unit/xfa_tohtml_spec.js
index 3f77e5c5b2ae09..1ecbf8711be8bd 100644
--- a/test/unit/xfa_tohtml_spec.js
+++ b/test/unit/xfa_tohtml_spec.js
@@ -64,6 +64,12 @@ describe("XFAFactory", function () {
foo
+
+
+
+ bar
+
+