diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 7e7eaac4b1234..7ae85eed251de 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -1207,6 +1207,25 @@ class Caption extends XFAObject { return HTMLResult.EMPTY; } + // For checkButton captions, add a non-breaking space at the beginning + // and replace all spaces with non-breaking spaces to prevent word wrapping + const parent = this[$getParent](); + if ( + parent?.ui?.checkButton && + typeof value === "object" && + value.children + ) { + for (const child of value.children) { + if (child.value && typeof child.value === "string") { + // Replace all regular spaces with non-breaking spaces + child.value = child.value.startsWith(" ") + ? child.value.replaceAll(" ", "\u00A0") + : "\u00A0" + child.value.replaceAll(" ", "\u00A0"); + child.value = child.value.replaceAll("/", "\u2044"); + } + } + } + const savedReserve = this.reserve; if (this.reserve <= 0) { const { w, h } = this[$getExtra](availableSpace); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index e2bb0f1e89e35..64e5112879077 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -93,6 +93,7 @@ !issue8372.pdf !issue9713.pdf !xfa_filled_imm1344e.pdf +!xfa_bug1716806.pdf !issue8424.pdf !issue8480.pdf !bug1650302_reduced.pdf diff --git a/test/pdfs/xfa_bug1716806.pdf b/test/pdfs/xfa_bug1716806.pdf new file mode 100644 index 0000000000000..4c523003b150b Binary files /dev/null and b/test/pdfs/xfa_bug1716806.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index f864c2be9e22e..16d5b7e46c4a4 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2120,6 +2120,14 @@ "enableXfa": true, "type": "eq" }, + { + "id": "xfa_bug1716806", + "file": "pdfs/xfa_bug1716806.pdf", + "md5": "ed78b522c661e744f780ab9b6d09fd8d", + "rounds": 1, + "enableXfa": true, + "type": "eq" + }, { "id": "xfa_bug1716809", "file": "pdfs/xfa_bug1716809.pdf",