2013-06-03 110 views
0

我使用mPDF從PHP生成的網站即時創建PDF。從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,它的工作原理。

感謝

+1

刪除你有沒有迴音......你不能有一個文件輸出如果你已經輸出了東西。 –

+0

請求前始終使用搜索引擎。 – str

+0

$ mpdf->輸出嘗試設置內容類型標題。但它不能夠,因爲你已經開始輸出(使用回聲),只需將其刪除 – x4rf41

回答

1

刪除你的下面一行:

echo $numPresup; 
1

將文件轉換爲UTF沒有BOM ;-)