Skip to content

Commit

Permalink
XFA - Fix indentation for justified paragraph
Browse files Browse the repository at this point in the history
  - and ceil the reserve for a caption to avoid to split it;
  - both issues are present in the pdf in issue mozilla#13633.
  • Loading branch information
calixteman authored and bh213 committed Jun 3, 2022
1 parent 43b6384 commit 9133062
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/core/xfa/html_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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 @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/xfa_issue13633.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://web.archive.org/web/20210703155102/https://www.jobcenter-remscheid.de/files/jobcenter-remscheid/download/anzeige-kug101_ba013134.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9133062

Please sign in to comment.