TCPDF - built-in ttf fonts that are not displayed when viewing PDF on iPad

I created a website that dynamically creates PDF using tcpdf and embeds fonts in PDF. The user can choose from a number of standard fonts, such as Arial, Verdana, etc. The system then selects the ttf font directly from my server and embeds it using the code below. Text with this font can be seen in most cases for viewing in pdf format, but the iPad/iPhone's viewer did not display it. I downloaded the new (random) version of Arial.ttf as a test (not sure about the difference in the file, but now it looks fine.

I need to do this for several fonts, but I shoot in the dark because I don’t know what in a font can cause it to not embed. Does anyone know that in ttf fonts will not be displayed? Shows great results for other viewers and shows that will be embedded in the Acrobat document properties?

thanks

 $fontname = $pdf->addTTFfont('/tcpdf/fonts/custom/'.$ttfFile.'.ttf', 'TrueTypeUnicode', '', 32); 

// use font

 $pdf->SetFont($fontname, '', $fontPoints, '', 'false'); 
+7
source share
1 answer

Invalid parameter for the $ subset. You set the value to false (with quotes). It must be logical.

  <?php ... // Wrong $pdf->SetFont($fontname, '', $fontPoints, '', 'false'); // Right $pdf->SetFont($fontname, '', $fontPoints, '', true); ... ?> 

Why does it work?

Because it inserts the whole font, not just a subset. The trick is to set the $ subset parameter in the $ pdf-> SetFont () method to true.

http://www.tcpdf.org/doc/code/classTCPDF.html#a471562985997be1573d387f0aeae6964

PDF works with

iPad (iOS 7), iPhone (iOS 7), Windows 7, MACOSX 10.9.

My PDF Creation Environment

Apache 2 on MAC 10.9, PHP 5.3.x, TCPDF v6.0.078

Files

Example PDF and PHP Script to create it

+2
source

All Articles