1.内容未以pdf格式显示
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/x-download");
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$pdf = new mPDF();
$content="'gAAAAgABwESAAMAAAABAAEAAAEaA";
$pdf->WriteHTML($strContent);
$pdf->Output($filename, 'D');
/*content is not displaying in PDF file, But it is displaying in web page when echo the content */
答案 0 :(得分:0)
首先,您尚未设置正确的内容类型标题,因此PDF将输出到浏览器。
改变这个:
header("Content-Type: application/x-download");
为:
header("Content-Type: application/pdf");
其次,生成PDF的代码看起来不正确。例如,您的html内容位于$content
,但是当您在pdf对象上编写时,您正在使用$strContent
等...
试试这个:
// Set Header
header("Content-Type: application/pdf");
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
// Generate & Output PDF
$pdf = new mPDF();
$content="'gAAAAgABwESAAMAAAABAAEAAAEaA";
$pdf->WriteHTML($content);
$pdf->Output();