我正在使用smarty模板动态生成一个页面,其中包含用户提交的表单数据和上传的图像。我可以按预期显示所有内容。我希望输出相同的PDF。该模板名为index.tpl,位于template文件夹中。我想不出怎么把这两个放在一起。任何帮助都会很感谢,谢谢。我尝试了以下方法,但不起作用。没有输出。
require_once("dompdf/dompdf_config.inc.php");
$html = $smarty->fetch('index.tpl');
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("pdf_file.pdf");当我检查error_log时,我注意到"PHP致命错误:类'DOMPDF‘没有找到“行。但是,当我创建了一个如下所示的简单文件时,我可以让它完美地工作(生成PDF)。
require_once("dompdf/dompdf_config.inc.php");
$html =
'<html><body>'.
'<p>Hello World!</p>'.
'</body></html>';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("pdf_file.pdf");这是怎么回事?为什么会有不同?
发布于 2013-10-22 18:03:29
我想你的答案就在这里http://www.smarty.net/docsv2/en/api.fetch.tpl
// capture the output
$output = $smarty->fetch('index.tpl');
$tmpfile = tempnam("/tmp", "dompdf_");
file_put_contents($tmpfile, $output);
...https://stackoverflow.com/questions/19514556
复制相似问题