从PHP生成的网站创建PDF时出错

时间:2013-06-03 14:04:19

标签: php html pdf mpdf

我正在使用mPDF从PHP生成的站点动态创建PDF。

我的代码如下所示:

ini_set('memory_limit', '-1');
include('../mpdf/mpdf.php');
$numPresup = "presupuesto_".$_GET['numPresup'].".html";
echo $numPresup;
$mpdf=new mPDF();
$stylesheet = file_get_contents('design.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML(file_get_contents($numPresup));
$mpdf->Output();
unlink($numPresup);
exit;

但我一直收到这个错误:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhost/artidental.com/home/html/Presupuestos/pdfExport.php:5) in /var/www/vhost/artidental.com/home/html/mpdf/mpdf.php on line 7049

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhost/artidental.com/home/html/Presupuestos/pdfExport.php:5) in /var/www/vhost/artidental.com/home/html/mpdf/mpdf.php on line 1727
mPDF error: Some data has already been output to browser, can't send PDF file

有关问题的任何线索? PDF文件工作正常,因为我用“Hello World”测试PDF并且它可以工作。

由于

2 个答案:

答案 0 :(得分:1)

删除以下行:

echo $numPresup;

答案 1 :(得分:1)

将文件转换为没有BOM的UTF; - )