mPDF错误:某些数据已经输出到浏览器 [英] mPDF error: Some data has already been output to browser

查看:153
本文介绍了mPDF错误:某些数据已经输出到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用mpdf将HTML转换并显示为PDF

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

当我在本地PC/服务器上运行它时,我看到了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错误:某些数据已经输出到浏览器,无法发送PDF文件

$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;

可以是文件夹权限吗?

推荐答案

我成功地解决了该问题,方法是将包含mpdf代码的.php文件的编码从UTF-8更改为ANSI!

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

注意:文件编码不会影响 $ htmlStr 变量的内容,因此输出可以是您希望的任何字符集(utf-8等) ).

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

这篇关于mPDF错误:某些数据已经输出到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆