Hostbill HostBill uses mPDF 5 8 to generate pdf PDF documents, you . You can refer to its documentation for further guidance on configuration files.: httphttps://wwwmpdf.mpdfonlinegithub.com/repos/mpdfmanual.pdfio/
Uploading font files
To be able to use custom fonts in pdf documents you will have to upload those font files to hbf/libs/mpdf/ttfonts directory.
...
In this guide we will use Open Sans font with four styles (bold, italic, ...), if . If your font has only one file you should treat it as a "regular" style.
In case of Open Sans fonts you should have this the following file structure:
Code Block |
---|
hbf/libs/mpdf/ttfonts/OpenSans-Regular.ttf hbf/libs/mpdf/ttfonts/OpenSans-Bold.ttf hbf/libs/mpdf/ttfonts/OpenSans-Italic.ttf hbf/libs/mpdf/ttfonts/OpenSans-BoldItalic.ttf |
Setting up custom fonts - after 2023-11-20 release
Each font that you want to use has to be added into $config
array under mPDF.fontdata
key in includes/config.php
file:
Font family name (array key) used in configuration has to be lower case, without spaces. If you use "OpenSans" as your css font-familly HostBill will look for "opensans".
Font file name (OpenSans-Regular.ttf) is case-sensitive.
Code Block | ||
---|---|---|
| ||
$config['mPDF.fontdata'] = [
'opensans' => [
'R' => 'OpenSans-Regular.ttf',
]
]; |
You can define 4 font styles under the same name, the R (Regular) variant is required for each font family, B (Bold), I (Italic), BI (Bold Italic) are optional.
If you specify additional variants it will allow mpdf to use correct fonts if you use font-weight or font-style properties in your CSS.
Code Block | ||
---|---|---|
| ||
$config['mPDF.fontdata'] = [
'opensans' => [
'R' => 'OpenSans-Regular.ttf',
'B' => 'OpenSans-Bold.ttf',
'I' => 'OpenSans-Italic.ttf',
'BI'=> 'OpenSans-BoldItalic.ttf'
]
]; |
Setting up custom fonts - before 2023-11-20 release
Info | ||
---|---|---|
| ||
Version 2023-11-20 brings major mPDF version update, the file hbf/libs/mpdf/config_fonts.php no longer works and is ignored, ensure to migrate your custom configuration into method described above |
Each font that you want to use has to be added in hbf/libs/mpdf/config_fonts.php
configuration file.
Font family name (array key) used in configuration has to be lower case, without spaces, if . If you use "OpenSans" as your css font-familly hostbill HostBill will look for "opensans".
...
You can define 4 font styles under the same name, the R (Regular) variant is required for each font famillyfamily, B (Bold), I (Italic), BI (Bold Italic) are optional.
...
Code Block | ||
---|---|---|
| ||
$this->fontdata = array( //... 'opensans' => [ 'R' => 'OpenSans-Regular.ttf', 'B' => 'OpenSans-Bold.ttf', 'I' => 'OpenSans-Italic.ttf', 'BI'=> 'OpenSans-BoldItalic.ttf' ], //... ); |
Note | ||
---|---|---|
| ||
If you are using auto upgrade, you should add |
Accessing fonts
You will have to define font-family directly in html when editing invoice template, to . To do that click on "html" button available in formatting tools, this will open a popup with html source for you to edit.
If you want to apply your font to the whole document, add or replace your style at the beginning with this code:
...