【发布时间】:2016-05-01 20:08:59
【问题描述】:
我似乎无法定位 dompdf 文件夹之外的文件,我发现我需要 $dompdf->set_option('isRemoteEnabled', true);
设置以允许脚本处理站点上的其他页面,但仍然没有运气。到目前为止,这是我的代码;
$dompdf = new DOMPDF;
$dompdf->set_option( 'isRemoteEnabled', true );
$html = file_get_contents("http://www.example.com/test.html");
$dompdf->load_html($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$pdf = $dompdf->output();
$dompdf->stream('test');
这给出了以下输出:
警告:file_get_contents(http://www.example.com/test.html):失败 打开流:HTTP 请求失败! HTTP/1.1 403 禁止在 /home/sites/www.example.com/web/wp-content/plugins/example/incl/dompdf.php 第 40 行
致命错误:带有消息的未捕获异常“Dompdf\Exception” '请求的 HTML 文档不包含数据。'在 /home/sites/www.example.com/web/wp-content/plugins/example/incl/dompdf/src/Frame/FrameTree.php:146 堆栈跟踪:#0 /home/sites/www.example.com/web/wp-content/plugins/example/incl/dompdf/src/Dompdf.php(572): Dompdf\Frame\FrameTree->build_tree() #1 /home/sites/www.example.com/web/wp-content/plugins/example/incl/dompdf/src/Dompdf.php(722): Dompdf\Dompdf->processHtml() #2 /home/sites/www.example.com/web/wp-content/plugins/example/incl/dompdf.php(43): Dompdf\Dompdf->render() #3 {main} 抛出 /home/sites/www.example.com/web/wp-content/plugins/example/incl/dompdf/src/Frame/FrameTree.php 在第 146 行
被调用的test.html 存在并且可以被浏览器访问。如果我用谷歌或雅虎之类的其他东西替换那个 URL,它也可以工作。 我错过了什么,这是服务器配置问题吗?
【问题讨论】:
标签: php wordpress plugins dompdf