本文介绍了MPDF无法在谷歌浏览器中工作,但在Firefox中可以正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用mPDF创建PDF文档时再次陷入困境.我已经完成了以下代码,这些代码在Firefox和Safari中可以正常工作,但在Google Chrome中无法正常工作.

Again am stuck into a situation while creating PDF document usong mPDF. I have done the following code which works fine in Firefox and Safari but not working in Google Chrome.

require_once 'mpdf60/mpdf.php';
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0;
$stylesheet = file_get_contents('css/style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($test, 2);
$mpdf->Output();

有人可以指导我如何解决此问题吗?

Can anyone please guide me on how to resolve this issue?

推荐答案

根据您的评论,在发送输出之前尝试以下操作:

According to your comment, try this before you send output:

ob_clean();
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $yourFileName . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');

require_once 'mpdf60/mpdf.php';
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0);

$mpdf->SetDisplayMode('fullpage');

$mpdf->list_indent_first_level = 0;
$stylesheet = file_get_contents('css/style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($test, 2);
$mpdf->Output();
ob_end_flush();

这篇关于MPDF无法在谷歌浏览器中工作,但在Firefox中可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 11:17
查看更多