TCPDF - how to add a font to pdf

When using TCPDF to create PDF files, I try to embed fonts in my pdf file. I read about this in the manuals, and I tried it for several hours.

I used this method:

$fontname = $pdf->addTTFfont('/fonts/aller.ttf', '', '', 32); 

After that, I have 3 files in the tcpdf fonts directory: aller.php, aller.z and aller.ctg.z I install the font as follows:

 $pdf->SetFont('aller', '', 20, '', true) 

Unfortunately, I get dots in a pdf file and the error message "Cannot extract the embedded font" AAAAAD + Aller, Bold. "Some characters may not be displayed or printed correctly."

I use windows, so I cannot use ttf2atm.exe and call php -q makefont.php, as suggested in some tutorials.

I found a link question here in SO, but there was no solution.

Does anyone know how to add a brand new font to a tcpdf pdf file? I want to add the font Aller (you can download it from here - just click on the link "pobieraj".

Help will be appreciated.

Kalreg.

The problem is resolved - unfortunately, the font I was trying to embed was damaged - any other works fine with the $ pdf-> addTTFfont () method.

+6
source share

Source: https://habr.com/ru/post/913262/


All Articles