自动下载mpdf生成pdf文档 [英] Auto download mpdf generated pdf document

查看:429
本文介绍了自动下载mpdf生成pdf文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆