1

I have html that uses some script fonts that need to be converted to pdf. I have everything working on this, except when I try and include the script fonts in the pdf it gives the the following error:
TCPDF ERROR: Could not include font definition file: 'stalemate'

The original font is from the Google Fonts library. Per instructions I have found, I renamed the font so that it was all lowercase, then made the matrix files using the ttf2ufm utility. I then took these files and used the makefont.php utility to make the needed files for the font to be included in the TCPDF font folder (stalemate.z, stalemate.ctg.z and stalemate.php). I have also tried putting them in a specific folder and pointing the call to that as well.

Seems like I have all the right files in all the right places and still get the above error. If I take out the style for that font on the html, the document PDFs just fine.

I have made a smaller test page at http://mattodesigns.com/pdfconverter.php, which take the html from http://mattodesigns.com/sample.html and converts it to a pdf. The following is the php code:
<?php require_once 'html2pdf_v4.03/html2pdf.class.php'; $url = 'http://mattodesigns.com/sample.html'; $source = file_get_contents($url); $html = str_replace(array("\r", "\n", "\t"), '', $source); $orientation = 'P'; $format = 'A4'; $margins = array(0,0,0,0); $html2pdf = new HTML2PDF($orientation, $format, 'en', true, 'UTF-8', $margins); $html2pdf->addFont('stalemate', '', 'stalemate.php'); $html2pdf->WriteHTML($html); $html2pdf->Output('first_PDF_file.pdf'); ?>

The HTML code that it pulls is:
<html> <head> <style> @font-face {font-family: "stalemate"; font-weight: 400; src: url(/fonts/stalemate.otf) format("opentype");} </style> </head> <body> <h1>Make Sure this is working</h1> <p style="font-family: 'stalemate', cursive ;">This is your first PDF File</p> </body> </html>

Addition: I found out that if I use setDefaultFont('stalemate') the font itself will load, but then all the text on the page is now just Stalemate. I need to have multiple fonts on the same page. Is this possible or is it just one font per document written?

2

Hello,

Why not include 2 addfont like this :

$html2pdf->addFont('stalemate1', '', 'stalemate1.php');
$html2pdf->addFont('stalemate2', '', 'stalemate2.php');

and place the font-family:'slatemate1'; in your CSS

Regards
Pat