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);
}
Run Code Online (Sandbox Code Playgroud)
致命错误:未捕获异常'DOMPDF_Exception',消息'找不到块级父级.不好.'
Joh*_*ner 15
末到本线程,但立足岗位在https://github.com/dompdf/dompdf/issues/902,我能够之间去掉空格来解决这个问题<html><head>,</head><body>和</body></html>
所以,而不是像这样正确格式化 html 代码:
<html>
<head>
...
</head>
<body>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我删除了标签之间的所有新行或空格,现在看起来像这样:
<html><head>
</head><body>
</body></html>
Run Code Online (Sandbox Code Playgroud)
一切又是愚蠢的多莉
Pra*_*mar 13
只需定义
$dompdf->set_option('enable_html5_parser', TRUE);
Run Code Online (Sandbox Code Playgroud)
我认为它会解决这个问题。
或者可以编辑 dompdf/dompdf_config.inc.php 文件转到第 322 行更改
def("DOMPDF_ENABLE_HTML5PARSER", false);
Run Code Online (Sandbox Code Playgroud)
到
def("DOMPDF_ENABLE_HTML5PARSER", true);
Run Code Online (Sandbox Code Playgroud)
DOMPDF文件夹> dompdf_config.custom.inc.php文件>尝试取消注释行
define("DOMPDF_ENABLE_HTML5PARSER",true);
同时用支持的html5标记和属性替换不支持的html5标记和属性,清除html错误以获得更好的结果
小智 5
如果您已使用 Composer require 安装了 dompdf,那么enable_html5_parser如果您不想修改供应商文件夹,则使用 set_option 方法定义选项效果很好
因此,将以下内容添加到产生错误的每个文档中
$dompdf->set_option('enable_html5_parser', TRUE);
Run Code Online (Sandbox Code Playgroud)
小智 4
转到配置文件 dompdf_config.custom.inc.php 并取消注释 Define("DOMPDF_ENABLE_HTML5PARSER", true); 并检查,基本上它需要在配置文件中启用 html5 解析器。