2017-07-17 42 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

相關問題