From 2af0abb800aaea0ec5ef372b901f117c18508fed Mon Sep 17 00:00:00 2001 From: danfickle Date: Sat, 29 Aug 2020 18:17:43 +1000 Subject: [PATCH] #543 Downgrade PDFBOX to 2.0.20 due to nbsp regression. PDFBOX 2.0.21 is now reporting nbsp as having zero width (in built-in fonts) which means line or justification involving this character will be wrong. Previously, in 20.0.20 it was reporting nbsp as not existing so we replace it with a normal space. With test kindly provided by @lagar84 --- .../expected/issue-543-nbsp-justify.pdf | Bin 0 -> 1811 bytes .../html/issue-543-nbsp-justify.html | 27 ++++++++++++++++++ .../VisualRegressionTest.java | 8 ++++++ openhtmltopdf-pdfbox/pom.xml | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-543-nbsp-justify.pdf create mode 100644 openhtmltopdf-examples/src/main/resources/visualtest/html/issue-543-nbsp-justify.html diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-543-nbsp-justify.pdf b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-543-nbsp-justify.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7cce326e0c555b9f6ee86452998d5f33144441b9 GIT binary patch literal 1811 zcmds2O>f#j5WUZ@mG;t1^2Hf`EJ+e?2#Pd#+j zK(eNaa_?GLyxDngXUE>>&gD2h6_x{?-@pF+1c4lj&v!5w0GoZkSIDBIPS(W=*e6w1 zS&<_XmJjSQS*Z#orB7iv1eK?nW*hXVR7p*QaZ)Snj^9WwIq%Cr^o8W&mEb3wpY%wn zEYj^lmDnxrReoD<)^%~8F0Dne=^4^`sdi;e3BcZEX@zq~S8@X^Dz4r?Dz@c+rGWa8{+Iv*YXjxt?f_k-r)3UKb-EEJOO7Bo76<}A}&vj$BIw*jJNu?Tn_ExRGsybUFz$W>kNV9x}>^jRwd6gXk zhTA=qYDp(Q0RA}8b6wj-3h##?kJ1ClBX&c0!EuQDRI46OSyIyW+acSg4YxwVmd9Gc z_Q*z$vI6>6>_c^#WNTG6ADwAYkbO5@V`urYK>bM}!#x}0eBiocXTl@Laiac6#$g-@ o;kjWPkAiU&%W#MksIlavtechzC*aWOOg_Z$7gOb#J^%m! literal 0 HcmV?d00001 diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-543-nbsp-justify.html b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-543-nbsp-justify.html new file mode 100644 index 000000000..1f25e53bd --- /dev/null +++ b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-543-nbsp-justify.html @@ -0,0 +1,27 @@ + + + + + + + +
+ CERTIFICATE registered under nº                , page         , in book nº        , process nº +
+ + + diff --git a/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java b/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java index ff80efb9a..524e3c9d1 100644 --- a/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java +++ b/openhtmltopdf-examples/src/test/java/com/openhtmltopdf/visualregressiontests/VisualRegressionTest.java @@ -1217,6 +1217,14 @@ public void testIssue474NpeImageDecoding() throws IOException { assertTrue(vt.runTest("issue-474-npe-image-decoding")); } + /** + * Tests that text justification works with nbsp. + */ + @Test + public void testIssue543NonBreakingSpaceJustify() throws IOException { + assertTrue(vt.runTest("issue-543-nbsp-justify")); + } + @Test public void testBarcode() throws IOException { diff --git a/openhtmltopdf-pdfbox/pom.xml b/openhtmltopdf-pdfbox/pom.xml index a9ffd99e3..9afd5da9e 100644 --- a/openhtmltopdf-pdfbox/pom.xml +++ b/openhtmltopdf-pdfbox/pom.xml @@ -119,7 +119,7 @@ - 2.0.21 + 2.0.20