Fatal error: Uncaught exception 'PDFlibException' with message 'Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pdf\index.php:2)'
in C:\xampp\htdocs\pdf\dompdf\include\pdflib_adapter.cls.php:833 Stack trace:
#0 C:\xampp\htdocs\pdf\dompdf\include\pdflib_adapter.cls.php(833): header('Cache-Control: ...')
#1 C:\xampp\htdocs\pdf\dompdf\include\dompdf.cls.php(447): PDFLib_Adapter->stream('sample.pdf', NULL)
#2 C:\xampp\htdocs\pdf\index.php(21): DOMPDF->stream('sample.pdf')
#3 {main} thrown in C:\xampp\htdocs\pdf\dompdf\include\pdflib_adapter.cls.php on line 833
有人遇到过这种错误吗?我正在使用DOMPDF。
这是我的代码:
<?php
if(isset($_POST['submit']))
{
$content = $_POST['content'];
if (empty($content)) {
$error = 'please enter some content to create your Pdf';
}
else{
include_once( 'dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->load_html($content);
$dompdf->render();
$dompdf->stream('sample.pdf');
}
}
?>
答案 0 :(得分:1)
在index.php的第2行发送输出:
output started at C:\xampp\htdocs\pdf\index.php:2
有时它只是一条空行! 复制粘贴整个index.php,请不要修改。