【发布时间】:2018-12-19 07:13:58
【问题描述】:
我正在使用带有 cakephp 3.6 的 dompdf 来生成从 HTML 到 PDF 的打印件
我在 drivercontroller 中有一个函数名称 test,我想加载一个在 src\Template\DriverDetails 中创建的 ctp 文件,文件名为 testpdf.ctp
你能帮我建议如何传递完整的文件。
下面是我的代码
public function test() {
$html = file_get_contents("testpdf.ctp");
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream("invoice.pdf", array("Attachment" =>0));
exit(0);
}
src\Template\DriverDetails\testpdf.ctp
<html>
<body>
<table>
<tr><td align="center"><?php echo $id; ?></td></tr>
<tr><td align="center">Demo Data</td></tr>
</table>
</body>
</html>
【问题讨论】:
标签: php cakephp pdf-generation cakephp-3.0 dompdf