diff --git a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/InlineText.java b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/InlineText.java index ce3e9ea72..8d66a9469 100644 --- a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/InlineText.java +++ b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/render/InlineText.java @@ -312,6 +312,10 @@ public float calcTotalAdjustment(JustificationInfo info) { // letter spacing is already explicitly set. return 0f; } + + if (_counts == null) { + return 0f; + } return (_counts.getSpaceCount() * info.getSpaceAdjust()) + (_counts.getNonSpaceCount() * info.getNonSpaceAdjust()); diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-420-justify-text-null-pointer-exception.pdf b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-420-justify-text-null-pointer-exception.pdf new file mode 100644 index 000000000..29219dce3 Binary files /dev/null and b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-420-justify-text-null-pointer-exception.pdf differ diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-420-justify-text-null-pointer-exception.html b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-420-justify-text-null-pointer-exception.html new file mode 100644 index 000000000..35f1cd635 --- /dev/null +++ b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-420-justify-text-null-pointer-exception.html @@ -0,0 +1 @@ +
a
b