【发布时间】:2014-06-01 07:46:38
【问题描述】:
您好,我正在编写一个脚本,该脚本将使用file_get_contents 动态加载 html,并将生成并保存在服务器上的 pdf,但不知何故,我的 php 文件给了我 500 内部服务器错误 所以有没有其他方法可以将 html 加载到 dompdf
这是我的代码
<?php
error_reporting(E_ALL);
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');
require_once("dompdf_config.inc.php");
$mvouch = $_REQUEST["vouchno"];
$dompdf = new DOMPDF();
$html =file_get_contents("http://www.myurl.com/project/file_to_be_loaded.php?vouchno=$mvouch");
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
file_put_contents("/files/report.pdf", $output);
echo "<h1>DONE!!!</h1>";
?>
【问题讨论】:
-
您可以访问 wkhtmltopdf 吗?我发现它是从 HTML 创建 PDF 的更好的库和工具。如果要解决 500 错误,则需要查看 php error_log 文件(linux:/var/log/apache2/error_log 或 /var/log/nginx/error_log)以查看处理器抛出的内容消息。
-
另外,include & (
include ('includes...'); -
它告诉我这个错误
Fatal error: Class 'DOMDocument' not found in /home/cepheisys/public_html/sbsweb/include/dompdf.cls.php on line 629 -
这意味着你没有安装 libxml 和 XML php 库。在手机上所以无法链接,但谷歌'php install xml'
-
正如贾斯汀所说,您缺少 DOMDocument,这是一个核心 PHP 扩展。它默认启用,但一些托管服务提供商明确禁用它。见php.net/manual/en/dom.setup.php。
标签: php html mysql dynamic-data dompdf