mPDF error: Some data has already been output to browser

旧城冷巷雨未停 提交于 2019-12-01 12:28:11

问题


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).



来源:https://stackoverflow.com/questions/46427975/mpdf-error-some-data-has-already-been-output-to-browser

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