From 913306295e2cf5e6c5980807161d7ae3855ac7a8 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sat, 3 Jul 2021 18:06:59 +0200 Subject: [PATCH] XFA - Fix indentation for justified paragraph - and ceil the reserve for a caption to avoid to split it; - both issues are present in the pdf in issue #13633. --- src/core/xfa/html_utils.js | 10 ++++------ src/core/xfa/template.js | 2 +- test/pdfs/xfa_issue13633.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 test/pdfs/xfa_issue13633.pdf.link diff --git a/src/core/xfa/html_utils.js b/src/core/xfa/html_utils.js index 2faff3608c0e5..c089202b80e5f 100644 --- a/src/core/xfa/html_utils.js +++ b/src/core/xfa/html_utils.js @@ -529,12 +529,10 @@ function fixTextIndent(styles) { } // If indent is negative then it's a hanging indent. - const align = styles.textAlign || "left"; - if (align === "left" || align === "right") { - const name = "padding" + (align === "left" ? "Left" : "Right"); - const padding = getMeasurement(styles[name], "0px"); - styles[name] = `${padding - indent}px`; - } + const align = styles.textAlign === "right" ? "right" : "left"; + const name = "padding" + (align === "left" ? "Left" : "Right"); + const padding = getMeasurement(styles[name], "0px"); + styles[name] = `${padding - indent}px`; } function setAccess(node, classNames) { diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index be343f20112c1..12a6433b142f3 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -897,7 +897,7 @@ class Caption extends XFAObject { "inactive", "invisible", ]); - this.reserve = getMeasurement(attributes.reserve); + this.reserve = Math.ceil(getMeasurement(attributes.reserve)); this.use = attributes.use || ""; this.usehref = attributes.usehref || ""; this.extras = null; diff --git a/test/pdfs/xfa_issue13633.pdf.link b/test/pdfs/xfa_issue13633.pdf.link new file mode 100644 index 0000000000000..e3e87a74d669b --- /dev/null +++ b/test/pdfs/xfa_issue13633.pdf.link @@ -0,0 +1 @@ +https://web.archive.org/web/20210703155102/https://www.jobcenter-remscheid.de/files/jobcenter-remscheid/download/anzeige-kug101_ba013134.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index c644f474588cf..6e4e1df8968ad 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1130,6 +1130,14 @@ "enableXfa": true, "type": "eq" }, + { "id": "xfa_issue13633", + "file": "pdfs/xfa_issue13633.pdf", + "md5": "e5b0d09285ca6a140eba08d740be0ea0", + "link": true, + "rounds": 1, + "enableXfa": true, + "type": "eq" + }, { "id": "xfa_issue13631", "file": "pdfs/xfa_issue13631.pdf", "md5": "bf24397950dc8b8fcb7e91299af1315a",