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


Error when creating a PDF from a PHP generated website

我正在使用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文件工作良好,因为我测试了PDF与"Hello World",它的工作。

谢谢

删除以下行:

echo $numPresup;

将文件转换为不含BOM的UTF格式;-)