gpt4 book ai didi

php - dompdf:加载要渲染的 html 文件,不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:58:35 24 4
gpt4 key购买 nike

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

所以,我不知道是 url 问题还是其他问题。这是我得到的错误:

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

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 在本地运行时会尝试各种东西/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();
?>

关于php - dompdf:加载要渲染的 html 文件,不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3248199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com