Reputation: 127
Does anybody can help me how to install or add new font in TCPDF. I already got the .z
,php
and .ttf
file in my font. And how to display or use the font.. I stored the given file into fonts folder.
I used CodeIgniter.
Upvotes: 1
Views: 7213
Reputation: 11
If you don't want to rely upon a third party website for converting the fonts (be it because you are reluctant to run executable code generated from an untrusted third party or simply because these sites are no longer there, like xml-convert.com), you can use TCPDF's script TCPDF/tools/tcpdf_addfont.php
.
php TCPDF/tools/tcpdf_addfont.php --help
For each TTF file, it will generate a .z
, a .php
and a .ctg.z
file, which you will need to put in your TCPDF fonts directory.
Then you can use it in the SetFont()
method. Remember you may need to generate files for all variants you plan to use (regular, italic, bold, bold italic etc.).
Upvotes: 0
Reputation: 6135
TCPDF: How to add new custom font in tcpdf
customfontname.php
and customfontname.z
/yourproject/vendor/tecnickcom/tcpdf/fonts/
folder$pdf->SetFont('customfontname', '', 12);
Upvotes: -1
Reputation: 837
Have you checked this?
something like this should work I think.
$fontname = $pdf->addTTFfont('/path-to-font/DejaVuSans.ttf', 'TrueTypeUnicode', '', 32);
Upvotes: 1
Reputation: 216
You can do the below thing. If you have .ttf file for the new font then convert that font to .php and .z files using below link http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf
Once you converted the fonts download the .php and .z file and upload it into tcpdf's fonts folder. TCPDF will consider your filename as your fontname so make sure you have correct file names.
Once files are uploaded you can directly use setfont function of tcpdf.
Upvotes: 4