zoukankan      html  css  js  c++  java
  • php利用mpdf生成pdf并保存到目录

    下载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文件夹下
        }
    }
    ?>
  • 相关阅读:
    $dp$模板
    字符串基础
    基础算法

    图论
    山中无甲子,寒尽不知年
    模板集合(持续更新)
    数学基础——同余
    9.19 考试总结
    1-5-17:菲波那契数列
  • 原文地址:https://www.cnblogs.com/houdj/p/8939639.html
Copyright © 2011-2022 走看看