PHP系列 | mPdf字体库异常 Cannot find TTF TrueType font file "Eeyek.ttf" in configured font directories

今天使用MQ任务队列导出学员的成果规划书为PDF格式,钉钉机器人报错

提示信息很明显,字体库不存在

解决办法

1、下载Eeyek.ttf字体库,下载地址:https://wiot.coding.net/s/75961591-152d-49b3-a79e-d0d90525e68e

2、修改配置:https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html

3、最后配置文件修改

$defaultConfig = $defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$pdfConfig = [
    "autoScriptToLang" => true,
    "autoLangToFont" => true,
    "setAutoTopMargin" => "stretch",
    "setAutoBottomMargin" => "stretch",
    "autoMarginPadding" => 10,
    'tempDir' => app()->getRuntimePath(),
    'mode' => 'UTF-8',
    'format' => 'A3',
    'default_font_size' => 14,
    'margin_right' => 12,
    'margin_left' => 12,
    'fontDir' => array_merge($defaultConfig['fontDir'], [public_path() . 'font'])
];
$mPdf = new Mpdf($pdfConfig);

 

 
posted @ 2022-10-21 16:44  Tinywan  阅读(21)  评论(0编辑  收藏  举报