我检查了大量的资源,但我的问题无法解决。我试图通过包含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,但面临错误“头已发送” –