dompdf无法从我网站的页面生成pdf。但是,我保存了页面并将其作为简单的静态html文件上传,并且有效!
所以,我不知道问题是否与url或其他内容有关..这是我得到的错误:
警告:require_once(/home/o110334/public_html/dompdf/include/firephp.cls.php)[function.require-once]:无法打开流:/ home / o110334 / public_html /中没有此类文件或目录第194行的dompdf / dompdf_config.inc.php
致命错误:require_once()[function.require]:无法打开所需的'/home/o110334/public_html/dompdf/include/firephp.cls.php'(include_path ='。:/ usr / lib / php:/第194行/home/o110334/public_html/dompdf/dompdf_config.inc.php中的usr / local / lib / php')
这是代码:
$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");
答案 0 :(得分:13)
DOMPDF在运行本地时尝试各种各样的东西/ eval,你最好尝试:
1)通过http:
请求HTML的(授予的,长途旅行)$dompdf->load_html_file('http://yourdomain.ext/'.$file);
2)不要让DOMPDF eval
使用输出缓冲本身,让DOMPDF加载生成的HTML字符串。
<?php
ob_start();
//be sure this file exists, and works outside of web context etc.)
require("admin/store/orders/45/invoice/print");
$dompdf = new DOMPDF();
$dompdf->load_html(ob_get_clean());
$dompdf->render();
?>