diff --git a/src/Dompdf.php b/src/Dompdf.php index 40329063f..bfb1c2b1b 100644 --- a/src/Dompdf.php +++ b/src/Dompdf.php @@ -490,6 +490,16 @@ public function loadHtml($str, $encoding = 'UTF-8') $doc->loadHTML($str); $doc->encoding = $encoding; + // Remove #text children nodes in nodes that shouldn't have + $tag_names = array("html", "table", "tbody", "thead", "tfoot", "tr"); + foreach ($tag_names as $tag_name) { + $nodes = $doc->getElementsByTagName($tag_name); + + foreach ($nodes as $node) { + self::removeTextNodes($node); + } + } + // If some text is before the doctype, we are in quirksmode if (preg_match("/^(.+)