我正在尝试在一个worpdress页面上实现DOMPDF库。该页面有一个自定义模板,因此我将此代码放在那里:
<?php /**
/*
* Template name: Prova
*/
get_header();
require_once (get_template_directory() . '/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$html =
'<html><body>'.
'<p>Put your html here, or generate it with your favourite '.
'templating system.</p>'.
'</body></html>';
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
get_footer();
?> 页面加载正确,我可以看到模板的页眉和页脚,但dompdf似乎不起作用,因为没有生成pdf。路径是正确的。未显示错误消息。我是不是遗漏了什么?
谢谢
发布于 2015-01-30 20:18:55
$dompdf->stream("/try/your/directory/path/sample.pdf");给它一些路径,并检查它是在相应的文件夹中创建的,还是根据您的语法在not..Ideally中创建的,它应该在代码文件所在的文件夹中。
https://stackoverflow.com/questions/28235717
复制相似问题