我想将导出数据导入pdf文件,所以我尝试使用mpdf。我正在按照其教程的一步一步,但我收到错误
Fatal error: Call to a member function WriteHTML() on null in C:\xampp\htdocs\laboratorium\application\controllers\beranda.php on line 506
在控制器中
$this->load->library('M_pdf');
$this->load->model('mod');
$data['result'] = $this->mod->getReport();
$html = $this->load->view('report', $data);
$this->M_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "D");
我确信$html
不是空的。我尝试加载它,它正在工作。为什么会这样?
答案 0 :(得分:2)
试试这个
$this->load->library('M_pdf');
$this->load->model('mod');
$data['result'] = $this->mod->getReport();
$html = $this->load->view('report', $data,true);
$this->m_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "D");