error MPDF error: Some data has already been output to browser

0

Hello,

I'm having a very strange error using the mPDF library to generate PDF.

The page fetches data from the database and displays it on the page and mPDF in turn generates the pdf.

However, when I do not generate the pdf the data is displayed, but if gero pdf does not display anything just this error msg:

  

mPDF error: Some data has already been output to browser, can not send PDF file

But if I do not ask you to manage the pdfs from the database, the pdf is normally displayed.

Remembering that the mpdf folder is allowed (I left it with 777) to see that, but it did not work.

Code for PDF generation:

define('MPDP_PATH', 'MPDF54/');

include(MPDP_PATH.'mpdf.php');
$mpdf=new mPDF(); 
$mpdf->SetDisplayMode('fullpage');

$mpdf->WriteHTML($html);
$mpdf->Output();
    
asked by anonymous 05.11.2015 / 18:45

1 answer

2

Do this:

define('MPDP_PATH', 'MPDF54/');

include(MPDP_PATH.'mpdf.php');

ob_clean();//Limpa o buffer de saída

$mpdf=new mPDF(); 
$mpdf->SetDisplayMode('fullpage');

$mpdf->WriteHTML($html);
$mpdf->Output();
    
05.11.2015 / 18:49