我有两个文件位于localhost/invoice
namedx.php
和template.php
中,然后我有一个这样的 URL:
localhost/invoice/template.php?name=wawan
如何将输出页面转换为 PDF?我想要的是访问x.php
然后获取转换后的template.php
. 我尝试使用 mpdf,但它不起作用。
这是x.php
:
<?php
include("MPDF54/mpdf.php");
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->WriteHTML(file_get_contents('template.php?name=wawan'));
$mpdf->Output();
?>
这是template.php
:
<div> The name is :
<?php
echo $_GET[name];
?>