2017-07-17 72 views
0

我知道如何做到这一点,使其在当地的环境中工作,我的字体.TTF到/vendor/mpdf/mpdf/ttfonts,然后加入如何自定义字体添加到卡尔蒂克警予,MPDF在yii2

$this->fontdata = array(
"calibri" => array(
'R' => 'calibri.ttf', 
'B' => 'calibrib.ttf', 
) 
... 

/vendor/mpdf/config-fonts.php

因此,现在我可以在我的PDF文件中使用Calibri字体,但是我应该如何正确使用它不仅在本地和composer update之后?

回答

0

解决方案,我发现:

1)提出的.ttf字体在/your/path/to/fonts/dir,与此内容添加custom_config.php

$this->fontdata["calibri"] = [ 
    'R' => 'calibri.ttf', 
    'B' => 'calibrib.ttf', 
]; 

2)在普通/ CONFIGS设置路径以自定义字体,并以文件自定义配置

'mpdfCustomFontsPath' => /your/path/to/custom_config.php, 
'mpdfCustomFonts' => /your/path/to/fonts/dir, 

3)Somethere创建卡尔蒂克/ PDF情况下做到这一点之前,你的代码:

$customFontsConfig = Yii::$app->params['mpdfCustomFontsPath']; 
$customFonts = Yii::$app->params['mpdfCustomFonts']; 
define("_MPDF_SYSTEM_TTFONTS_CONFIG", $customFontsConfig); 
define("_MPDF_SYSTEM_TTFONTS", $customFonts); 

,这将工作,因为MPDF将检查_MPDF_SYSTEM_TTFONTS_CONFIG_MPDF_SYSTEM_TTFONTS同时处理的HTML到PDF

相关问题