mPDF error: Some data has already been output to b

2019-02-20 10:28发布

问题:

I'm using mpdf to convert and display html to PDF

when i run it on my local pc/server i see the pdf, but when i run it on my site server i'm getting this error:

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

$url = "http://".SITE_DOMAIN."/itinPage-printVer.php?itinID=".$_GET['itinID'];
$htmlStr = file_get_contents($url);

include('html2pdf/mpdf.php');
//ob_end_clean();

$mpdf=new mPDF('utf-8');

$mpdf->WriteHTML( $htmlStr);
$mpdf->Output();   
exit;

Could it be folder permissions?

回答1:

I addressed the problem successfully by changing the encoding of the .php file which contains the mpdf code from UTF-8 to ANSI!

Note: The file encoding does not affect the contents of your $htmlStr variable, so the output can be in any character set you wish (utf-8, etc).



标签: php mpdf