Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Fix: Uncaught Dompdf\Exception: No block-level parent found. Not good
Browse files Browse the repository at this point in the history
Fatal error: Uncaught Dompdf\Exception: No block-level parent found.
Not good
  • Loading branch information
epreston authored and bsweeney committed Oct 24, 2017
1 parent ac40be1 commit ad41b6d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Dompdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("/^(.+)<!doctype/i", ltrim($str), $matches)) {
$quirksmode = true;
Expand Down

0 comments on commit ad41b6d

Please sign in to comment.