我正在使用带laravel 5的dompdf来生成配置文件的pdf但是它需要超过15分钟,然后它显示错误。流程就像浏览器中的打开显示配置文件页面,页面有链接下载为pdf与相同操作的URL(显示配置文件)与额外的参数pdf=yes
然后我使用if条件来检查pdf调用
Exception in PDF.php line 219: DOMDocument::loadHTML(): htmlParseEntityRef: no name in Entity, line: 41
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 104
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 110
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 116
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 122
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 128
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 134
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 140
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 145
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 150
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 155
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 160
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 165
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 170
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 177
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 188
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 193
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 211
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 216
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 222
DOMDocument::loadHTML(): ID personal-info-2 already defined in Entity, line: 227
DOMDocument::loadHTML(): Tag footer invalid in Entity, line: 330
DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 333
DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 334
DOMDocument::loadHTML(): Unexpected end tag : span in Entity, line: 355
DOMDocument::loadHTML(): Unexpected end tag : span in Entity, line: 358
file_get_contents(http://10.0.0.46:2000/front/css/bootstrap.min.css): failed to open stream: HTTP request failed!
Unable to load css file http://10.0.0.46:2000/front/css/bootstrap.min.css
file_get_contents(http://10.0.0.46:2000/front/font-awesome/css/font-awesome.min.css): failed to open stream: HTTP request failed!
Unable to load css file http://10.0.0.46:2000/front/font-awesome/css/font-awesome.min.css
file_get_contents(http://10.0.0.46:2000/front/css/styles.css): failed to open stream: HTTP request failed!
Unable to load css file http://10.0.0.46:2000/front/css/styles.css
file_get_contents(http://10.0.0.46:2000/front/css/custom-style.css): failed to open stream: HTTP request failed!
Unable to load css file http://10.0.0.46:2000/front/css/custom-style.css
file_get_contents(http://10.0.0.46:2000/front/css/custom-mediaqueries.css): failed to open stream: HTTP request failed!
Unable to load css file http://10.0.0.46:2000/front/css/custom-mediaqueries.css
file_get_contents(http://10.0.0.46:2000/front/images/logo.png): failed to open stream: HTTP request failed!
file_get_contents(http://10.0.0.46:2000/front/images/facebook.png): failed to open stream: HTTP request failed!
file_get_contents(http://10.0.0.46:2000/front/images/LinkedIn.png): failed to open stream: HTTP request failed!
file_get_contents(http://10.0.0.46:2000/front/images/Pinterest.png): failed to open stream: HTTP request failed!
file_get_contents(http://10.0.0.46:2000/front/images/Twitter.png): failed to open stream: HTTP request failed!
file_get_contents(http://10.0.0.46:2000/front/images/img-not-found.jpg): failed to open stream: HTTP request failed!
同一页面在浏览器中打开
答案 0 :(得分:0)
看起来您已将PHP通知/警告/错误设置为向浏览器显示。无论dompdf是否能够解析您的文档,您都不会获得预期的输出,因为:
因此,您应该禁止向浏览器发送通知。如果不是出于上述原因,那么因为它存在信息披露风险。如果您希望启用它们,则在使用dompdf(例如ini_set('display_errors', false);
)时至少应禁用它们。
话虽如此,您的文档结构存在一些问题:元素上的重复ID属性,不匹配的打开/关闭标记,无法识别的元素。您应该通过validator运行生成的HTML并尽可能多地解决问题。
最后,您的外部资源(CSS,图像)无法加载。网址错误或PHP设置allow_url_fopen
设置为false。