【发布时间】:2011-03-15 23:03:43
【问题描述】:
dompdf 无法从我的网站页面生成 pdf。但是,我已经保存了页面并将其上传为简单的静态 html 文件,并且成功了!
所以,我不知道问题出在 url 上还是其他问题。这是我得到的错误:
警告:require_once(/home/o110334/public_html/dompdf/include/firephp.cls.php) [function.require-once]:无法打开流:/home/o110334/public_html/ 中没有这样的文件或目录dompdf/dompdf_config.inc.php 第 194 行
致命错误:require_once() [function.require]: 无法打开所需的 '/home/o110334/public_html/dompdf/include/firephp.cls.php' (include_path='.:/usr/lib/php:/ usr/local/lib/php') 在 /home/o110334/public_html/dompdf/dompdf_config.inc.php 第 194 行
这是代码:
$file = "admin/store/orders/45/invoice/print"; // doesn't work
//$file = "invoice_sample2.html"; //it works (same web page, but stored in a html file)
$dompdf = new DOMPDF();
$dompdf->load_html_file($file);
$dompdf->render();
$dompdf->stream("sample.pdf");
【问题讨论】:
-
你在使用某种框架吗?我问是因为文件路径,它看起来像是框架可能使用的那种友好的 URL。如果是这样,Wrikken 指定的方法 #1 是您要使用的选项。除非您指定完整的 URL(例如 example.com/admin/store/orders/45/invoice/print),否则 DOMPDF 假定为本地文件系统路径。除非您通过 Web 服务器,否则框架不会处理该文件。