dompdf:加载要渲染的html文件,不起作用 [英] dompdf: loading html files to render, doesn't work

查看:110
本文介绍了dompdf:加载要渲染的html文件,不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dompdf无法从我的网站页面生成pdf。但是,我已经保存了页面并将其上传为简单的静态html文件,并且可以正常工作!

dompdf is not able to generate a pdf from a page of my website. However, I've saved the page and uploaded it as simple static html file, and it worked!

因此,我不知道问题是否出在URL上,或其他原因。.这是我得到的错误:

So, I don't know if the issue is with the url, or something else.. this is the error I get:


警告:require_once(/ home / o110334 / public_html / dompdf / include / firephp.cls.php)[function.require-once]:无法打开流:在第194行的/home/o110334/public_html/dompdf/dompdf_config.inc.php中没有这样的文件或目录

Warning: require_once(/home/o110334/public_html/dompdf/include/firephp.cls.php) [function.require-once]: failed to open stream: No such file or directory in /home/o110334/public_html/dompdf/dompdf_config.inc.php on line 194

严重错误:require_once()[function.require]:无法打开所需的'/home/o110334/public_html/dompdf/include/firephp.cls.php'(include_path ='。:/ usr / lib / php:/ usr / local / lib / php')在第194行的/home/o110334/public_html/dompdf/dompdf_config.inc.php中

Fatal error: require_once() [function.require]: Failed opening required '/home/o110334/public_html/dompdf/include/firephp.cls.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/o110334/public_html/dompdf/dompdf_config.inc.php on line 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");


推荐答案

DOMPDF在运行时会尝试各种东西/评估本地,最好尝试:

DOMPDF is trying all kinds of stuff/eval's when running local, you're better of trying:

1)通过http:

$dompdf->load_html_file('http://yourdomain.ext/'.$file);

2)不要让DOMPDF eval 但是使用输出缓冲本身,并让DOMPDF加载生成的HTML字符串。

2) Don't let DOMPDF eval but use output buffering itself, and let DOMPDF load the resulting string of 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();
?>

这篇关于dompdf:加载要渲染的html文件,不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆