美文网首页
php使用mpdf扩展将html转换成pdf

php使用mpdf扩展将html转换成pdf

作者: henryspace | 来源:发表于2020-11-18 14:07 被阅读0次
require_once APP_PATH . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf([
    'mode' => 'UTF-8', 'format' => 'A4', 'default_font_size' => 40, 'default_font' => '', 'margin_left' => 20, 'margin_right' => 20]);

$path = BASE_PATH. '/resource/' .date('YmdHis').'_'.mt_rand(1,5).'.pdf';
$mpdf->autoScriptToLang = true;//支持中文设置
$mpdf->autoLangToFont = true;//支持中文设置
$url = 'http://baidu.com’;
$strContent = file_get_contents($url);
$mpdf->WriteHTML($strContent);

$mpdf->Output($path,'f');
exit;

相关文章

网友评论

      本文标题:php使用mpdf扩展将html转换成pdf

      本文链接:https://www.haomeiwen.com/subject/mvrciktx.html