Dompdf - Chroot 无法在目录中找到文件

Dompdf - Chroot cant find file in Directory

当我尝试加载 HTML 文件时,该文件位于我的 Laravel 项目的存储目录中。我指定了正确的路径,文件就在那里。

我尝试将 html 文件移动到供应商地图中 dompdf 的根目录,但这没有帮助。 更改 chroot 的路径会使 dompdf 本身的其他部分混乱。给出有关无法找到字体的错误。

这是我得到的错误

`Permission denied on <!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div class="body">
<h2>test</h2>
<hr/>
<p class="content">content test</p>
</div>
</body>
</html>. The file could not be found under the directory specified by Options::chroot.`

我可以对 dompdf.php 或 Options.php 进行任何更改以使其正常工作吗?

Dompdf 限制从本地文件系统加载文件到 chroot 选项中设置的路径(默认为 dompdf 安装目录,ref)。

但是,这不是导致您出现问题的原因。该错误似乎表明您正在尝试使用 $dompdf->loadHtmlFile() 加载包含 HTML 文档的字符串。这就是您看到 HTML 文档内容而不是文件路径的原因。加载 HTML 文档时,请改用 $dompdf->loadHtml()

通过 dompdf 问题跟踪器中的讨论确认:https://github.com/dompdf/dompdf/issues/1239