diff --git a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/BoxBuilder.java b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/BoxBuilder.java index b9681cc0d..f76778f93 100644 --- a/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/BoxBuilder.java +++ b/openhtmltopdf-core/src/main/java/com/openhtmltopdf/layout/BoxBuilder.java @@ -993,6 +993,9 @@ private static BlockBox createBlockBox( BlockBox result; if (style.isTable() || style.isInlineTable()) { result = new TableBox(); + } else if (style.isTableCell()) { + info.setContainsTableContent(true); + result = new TableCellBox(); } else { result = new BlockBox(); } @@ -1357,7 +1360,9 @@ private static void insertAnonymousBlocks( for (Styleable child : children) { if (child.getStyle().isLayedOutInInlineContext() && - ! (layoutRunningBlocks && child.getStyle().isRunning())) { + ! (layoutRunningBlocks && child.getStyle().isRunning()) && + !child.getStyle().isTableCell() //see issue https://github.com/danfickle/openhtmltopdf/issues/309 + ) { inline.add(child); if (child.getStyle().isInline()) { diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-309-classcastexception-on-float-td.pdf b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-309-classcastexception-on-float-td.pdf new file mode 100644 index 000000000..1f34c6c0e Binary files /dev/null and b/openhtmltopdf-examples/src/main/resources/visualtest/expected/issue-309-classcastexception-on-float-td.pdf differ diff --git a/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-309-classcastexception-on-float-td.html b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-309-classcastexception-on-float-td.html new file mode 100644 index 000000000..08d6086cb --- /dev/null +++ b/openhtmltopdf-examples/src/main/resources/visualtest/html/issue-309-classcastexception-on-float-td.html @@ -0,0 +1 @@ +
a | x |