问题
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