问题描述
我是mpbdf的新手,所以不要介意,如果你觉得这个问题是愚蠢的一个:),
我生成了pdf文档usinf mPDF类,问题是在生成pdf后,浏览器在标签中打开它。但我希望它不会打开,但自动下载,我的代码就像follwing ..
include(../ mpdf。 PHP的);
$ html =我的HTML代码在这里!;
$ mpdf = new mPDF('c','A4','','',32,25,27,25,16,13);
$ mpdf-> SetDisplayMode('fullpage');
$ mpdf-> list_indent_first_level = 0;
$ stylesheet = file_get_contents('mpdfstyletables.css');
$ mpdf-> WriteHTML($ stylesheet,1);
$ mpdf-> WriteHTML($ html);
$ mpdf->输出('mpdf.pdf');
我预计会有一个函数在mpdf类中下载,如 $ mpdf->下载
而不是 $ mpdf->输出('mpdf.pdf')
。
添加'D'参数以供下载
$ mpdf->输出('MyPDF.pdf','D');
I am newbie for mpdf so don't mind if you feel this question is stupid one:),
I generated the pdf document usinf mPDF class , the issue is that after pdf generated the browser opens it in tab . But i want it not to open but auto download , My code is like follwing..
include("../mpdf.php");
$html="my HTML code here !";
$mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html);
$mpdf->Output('mpdf.pdf');
I am expecting that there will be a function to download in the mpdf class like $mpdf->download
instead $mpdf->Output('mpdf.pdf')
.I searched alot for this type solution but in vain i could't find any .
Add 'D' parameter for download
$mpdf->Output('MyPDF.pdf', 'D');
这篇关于自动下载mpdf生成pdf文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!