【发布时间】:2018-01-19 07:25:18
【问题描述】:
我正在使用 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 页面并在浏览器上显示该页面。
欢迎任何帮助。
【问题讨论】:
-
尝试“D”参数下载文件:
$this->m_pdf->pdf->Output($pdfFilePath,"D"); -
我尝试使用“D”,但它也不起作用。
-
我猜这与 CI 输出类有关 - 在您的行
$this->m_pdf->pdf->Output($pdfFilePath,"F");之后添加die();并再试一次
标签: codeigniter pdf mpdf