我檢查了大量的資源,但我的問題無法解決。我試圖通過包含PHP文件生成PDF。但現在我陷入「無法流式傳輸pdf:頭文件已發送」錯誤。我也壓縮我的代碼,並刪除空白。 這是我的代碼。無法下載PDF使用DOMPDF
<?php
//ob_start();
// include autoloader
require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$return = include 'download_pdf.php';
$return = stripslashes($return);
$dompdf->loadHtml($return);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
//$dompdf->stream();
// Output the generated PDF (1 = download and 0 = preview)
$dompdf->stream("codex",array("Attachment"=>0));
?>
'$收益率=包括 'download_pdf.php';'這並不信息載入'$ return',除非你在那個php文件中有'return',否則你可能會迴應一些會導致確切錯誤的東西你說你有。 – cmorrissey
Yess我沒有重新調用任何變量..我只是創建一個PHP文件的HTML,只包括該PHP文件..所以請建議我任何建議,以克服這個問題 –
還有一件事是當我回顯變量我可以在瀏覽器中看到整個HTML,但面臨錯誤「頭已發送」 –