0

我一直在流动这篇文章以生成 pdf,但输出为空白并且没有显示错误,我放了:

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

当我输入:

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();
}

提到这个答案,我得到这个错误:

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

2 回答 2

4

它正在使用 ob_end_clean()擦除输出缓冲区并关闭输出缓冲

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();
}
于 2012-11-08T14:56:22.720 回答
1

一些输出已经从您的脚本发送到浏览器。请检查您的源代码。您可能还想使用输出缓冲

于 2012-11-08T14:22:37.450 回答