Dompdf error “No block-level parent found. Not goo

2019-05-07 20:20发布

require_once("function/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
foreach($modules as $module){
   $output = "Hello " .$module['name'];
   $dompdf->load_html($output);
   $dompdf->render();
   $output_pdf = $dompdf->output();
   file_put_contents($dir . $name_modulo . ".pdf", $output_pdf);

}

Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No block-level parent found. Not good.'

标签: php dompdf
4条回答
Fickle 薄情
2楼-- · 2019-05-07 20:24

Just uncomment define("DOMPDF_ENABLE_HTML5PARSER", true); this line from dompdf_config.custom.inc.php this file.

You can find this file for codeigniter in vendor/dompdf/dompdf this directory.

查看更多
▲ chillily
3楼-- · 2019-05-07 20:25

go to configuration file dompdf_config.custom.inc.php and uncomment define("DOMPDF_ENABLE_HTML5PARSER", true); and check, basically it requires html5 parser enabled in your configuration file.

查看更多
时光不老,我们不散
4楼-- · 2019-05-07 20:47

I don't know why the answer regarding ("DOMPDF_ENABLE_HTML5PARSER", true) was voted down either. Because I spent over 30 hours trying to figure out why this was happening in my website, until I came across this solution. So I enabled the "DOMPDF_ENABLE_HTML5PARSER" by setting it to "TRUE" as noted above. And immediately the error regarding "No block-level parent found" was resolved and my scripts worked. Maybe the 2nd answer was voted down because it duplicated a previous answer (but cut a guy a break, why don't you? Maybe he didn't see it..). Or maybe the "downvoter" has an attitude problem.

查看更多
家丑人穷心不美
5楼-- · 2019-05-07 20:49

dompdf folder>dompdf_config.custom.inc.php file>try uncomment the line

define("DOMPDF_ENABLE_HTML5PARSER", true);

Also replace unsupported html5 tags & attributes with supported one,clear html errors for better result

查看更多
登录 后发表回答