错误在 mpdf 6.1 中没有设置字体或默认字体
Error No font or default font set in mpdf 6.1
我在我的系统中使用 codeigneiter 和 mpdf 6.1 来生成 pdf。当我在 ttfont 中添加新字体时,出现错误“ 未设置字体或默认字体!”,在我的 html 中打印代码:
$mpdf = new mPDF('utf-8','A4','');
$mpdf->fontDir = './third_party/mPDF/ttfont/'; /* location to save new font */
$mpdf->fontdata['ampleSoft'] = array(
'R' => "ampleSoft-bold.ttf",
'B' => "AmpleSoft-Medium.ttf",
);
$mpdf->SetFont('ampleSoft');
并在文件 config_fonts 中添加新代码:
'ampleSoft' => array(
'R' => 'AmpleSoft-Medium.ttf',
'B' => 'ampleSoft-bold.ttf'
)
这有什么问题吗?
fontDir
变量在 mPDF 6.x 中不可用。在 _MPDF_TTFONTPATH
常量中定义路径。您可能需要将使用过的字体文件从分发版复制到您的自定义目录。
https://mpdf.github.io/fonts-languages/fonts-in-mpdf-6-x.html
我在我的系统中使用 codeigneiter 和 mpdf 6.1 来生成 pdf。当我在 ttfont 中添加新字体时,出现错误“ 未设置字体或默认字体!”,在我的 html 中打印代码:
$mpdf = new mPDF('utf-8','A4','');
$mpdf->fontDir = './third_party/mPDF/ttfont/'; /* location to save new font */
$mpdf->fontdata['ampleSoft'] = array(
'R' => "ampleSoft-bold.ttf",
'B' => "AmpleSoft-Medium.ttf",
);
$mpdf->SetFont('ampleSoft');
并在文件 config_fonts 中添加新代码:
'ampleSoft' => array(
'R' => 'AmpleSoft-Medium.ttf',
'B' => 'ampleSoft-bold.ttf'
)
这有什么问题吗?
fontDir
变量在 mPDF 6.x 中不可用。在 _MPDF_TTFONTPATH
常量中定义路径。您可能需要将使用过的字体文件从分发版复制到您的自定义目录。
https://mpdf.github.io/fonts-languages/fonts-in-mpdf-6-x.html