Using mpdf with codeigniter generate blank output

谁说胖子不能爱 提交于 2020-01-06 19:17:27

问题


I have been flowing this post to generate a pdf but the output is blank and there is no error displayed , i have put :

public function generate_pdf()
{
    $this->load->library('mpdf');
    $mpdf=new mPDF('utf-8','A4');
    $mpdf->WriteHTML('<p>HTML content goes here...</p>');
    $mpdf->Output();
}

When i put :

public function generate_pdf()
{
    $this->load->library('mpdf');
    $mpdf=new mPDF('utf-8','A4');
    $mpdf->debug = true;
    $mpdf->WriteHTML('<p>HTML content goes here...</p>');
    $mpdf->Output();
}

referred to this answer , i get this error :

Output has already been sent from the script - PDF file generation aborted.

回答1:


it is working using ob_end_clean() that erase the output buffer and turn off output buffering

public function generate_pdf()
{
   ob_end_clean();
   $this->load->library('mpdf');
   $mpdf=new mPDF('utf-8','A4');
   $mpdf->debug = true;
   $mpdf->WriteHTML('<p>HTML content goes here...</p>');
   $mpdf->Output();
}



回答2:


Some output is already sent to the browser from your script. Please check your source code. You may want to use output buffering as well.



来源:https://stackoverflow.com/questions/13290779/using-mpdf-with-codeigniter-generate-blank-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!