我正在使用mPDF库从HTML页面生成PDF文件。它在firefox中运行良好,但在chrome浏览器中不显示PDF文件。
在Chrome中生成PDF时出现以下错误。
以下是我使用mPDF生成PDF的代码
ob_clean();
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $yourFileName . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
$mpdf = new PDF( 'c','A4','','',15, 15,10,14,0,0);
$mpdf->useOnlyCoreFonts = false;
$mpdf->SetDisplayMode('real');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$stylesheet = file_get_contents(APPPATH . 'third_party/mpdf/style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html);
$mpdf->Output();
这是人们在较旧版本的Chrome上遇到的问题。如果仍然遇到此问题,请执行以下操作
在Google Chrome浏览器中,您有2个查看PDF文件的选项。您可以使用Chrome pdf查看器(默认),也可以使用Adobe Reader
您可以检查chrome:// plugins(在地址栏中输入)吗?并只需启用即可切换到其他PDF查看器(Chrome / Adobe)!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句