Skip to content

Commit

Permalink
#543 Downgrade PDFBOX to 2.0.20 due to nbsp regression.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
danfickle committed Aug 29, 2020
1 parent 6854043 commit 2af0abb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style>
@page {
size: 320px 100px;
margin: 30px;
}
html {
font-family: sans-serif;
font-size: 14px;
}
body {
margin: 0;
max-width: 260px;
}

</style>
</head>
<body>

<div style="font-size: 8pt; text-align: justify;">
CERTIFICATE registered under nº &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;, page &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;, in book nº &#160;&#160;&#160;&#160;&#160;&#160;&#160;, process nº
</div>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion openhtmltopdf-pdfbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</build>

<properties>
<pdfbox.version>2.0.21</pdfbox.version>
<pdfbox.version>2.0.20</pdfbox.version>
</properties>

</project>

0 comments on commit 2af0abb

Please sign in to comment.