diff --git a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java index ed25adbbb..6d382b4f1 100644 --- a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java +++ b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/Breaker.java @@ -280,7 +280,8 @@ static LineBreakResult doBreakCharacters( nextCharBreak = charIterator.next(); } - if (graphicsLength == avail) { + if (graphicsLength == avail && + graphicsLength > 0) { // Exact fit.. boolean needNewLine = currentString.length() > left; @@ -314,7 +315,8 @@ static LineBreakResult doBreakCharacters( graphicsLength += splitWidth; } - if (graphicsLength <= avail) { + if (graphicsLength <= avail && + graphicsLength > 0) { // The entire word fit. context.setWidth(graphicsLength); context.setEnd(nextCharBreak + context.getStart()); @@ -361,6 +363,7 @@ static LineBreakResult doBreakCharacters( // Empty string. context.setEnd(context.getStart()); context.setWidth(0); + context.setNeedsNewLine(false); return LineBreakResult.CHAR_BREAKING_FINISHED; } diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-466-infinite-loop-table-cell-box.pdf b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-466-infinite-loop-table-cell-box.pdf new file mode 100644 index 000000000..ac67ed56f Binary files /dev/null and b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-466-infinite-loop-table-cell-box.pdf differ diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-466-infinite-loop-table-cell-box.html b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-466-infinite-loop-table-cell-box.html index 5ff10cdfd..b4c702cae 100644 --- a/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-466-infinite-loop-table-cell-box.html +++ b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-466-infinite-loop-table-cell-box.html @@ -1,6 +1,31 @@ +
ABC |