我正在使用mpdf生成pdf。它实际上将HTML文件转换为pdf。 HTML文件被一些数据填满。控制器中的代码是:
$pdfFilePath = APPPATH.'invoice/firstinvoice1901.pdf';
//load mPDF library
$this->load->library('m_pdf');
$html = $this->load->view('admin/payments/viewinvoice',$this->data,true);
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//save it on server.
$this->m_pdf->pdf->Output($pdfFilePath,"F");
现在运行代码后,它不会生成pdf,而是填充html页面并在浏览器上显示此页面。
欢迎任何帮助。
$ mpdf->输出('MyPDF.pdf','D');
要么
$filename = "fileName.pdf";
if (file_exists($filename)) {
header('Content-type: application/force-download');
header('Content-Disposition: attachment; filename='.$filename);
readfile($filename);
}