首页 > 编程语言 >php 导出图片为pdf

php 导出图片为pdf

时间:2022-11-15 14:13:09浏览次数:42  
标签:Mpdf mpdf 导出 html exit pdf php

require_once ROOTPATH . 'tcpdf/vendor/autoload.php';$html='';if($html){
    mpdf($html);
}else{
    echo "下载失败,请选择资源";
    die();
}
function mPdf($html, $fileName = 'dome', $dest = "D")
{
    $mpdf = new \Mpdf\Mpdf();
    $mpdf->SetDisplayMode('fullpage');
    $mpdf->autoScriptToLang = true;
    $mpdf->autoLangToFont = true;

    $mpdf->WriteHTML($html);
    $mpdf->Output($fileName . ".pdf", $dest);
    // 输出pdf文件(必须写exit结束,否则会出现下载正常,预览全部乱码问题)
    exit();
}

 

标签:Mpdf,mpdf,导出,html,exit,pdf,php
From: https://www.cnblogs.com/lhjy1/p/16892228.html

相关文章