0

我正在使用 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 并且它工作正常。

谢谢

4

2 回答 2

1

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

于 2014-10-08T08:01:37.903 回答
1

删除以下行:

echo $numPresup;
于 2013-06-03T14:07:28.583 回答