下载mpdf7.0两种方法
(1)、 github地址:https://github.com/mpdf/mpdf
(2)、 composer require mpdf/mpdf
<?php error_reporting(0); set_time_limit(0); include('../common/conn.php'); require_once __DIR__ . '/../vendor/autoload.php'; $mpdf = new MpdfMpdf(); $sign=@$_GET['sign']; if($sign==''){ //获取全部门店信息 $branch="SELECT top 2 a.cCusCode,a.cCusName,a.cCusPerson,a.cCusPhone,a.cCusHand,a.cCusOAddress,c.cDepName FROM dbo.Customer a LEFT JOIN dbo.CustomerClass b on a.cCCCode=b.cCCCode LEFT JOIN dbo.Department c on a.cCusDepart=c.cDepCode where b.cCCCode like '300%'"; }else{ $branch="SELECT a.cCusCode,a.cCusName,a.cCusPerson,a.cCusPhone,a.cCusHand,a.cCusOAddress,c.cDepName FROM dbo.Customer a LEFT JOIN dbo.CustomerClass b on a.cCCCode=b.cCCCode LEFT JOIN dbo.Department c on a.cCusDepart=c.cDepCode where a.cCusCode ='$sign'"; } $branchList=$db->getAll($branch); $branchList=array_iconv($branchList); if(is_array($branchList) && count($branchList)){ foreach($branchList as $key=>$val){ $html = file_get_contents("http://172.16.6.20:2222/pdf/branch.php?sign=$val[cCusCode]"); //加载要生成pdf的文件 //设置pdf显示方式 $mpdf->SetDisplayMode('fullwidth'); $mpdf->autoScriptToLang = true; $mpdf->autoLangToFont = true; $mpdf->WriteHTML($html); $filename= iconv("utf-8","gb2312",$val['cCusName']).".pdf"; $path="./files/".$filename; $mpdf->Output($path,'f'); //保存至当前file文件夹下 } } ?>