2

some of the fonts like ArialMT, Arial-boldMT, PTSans-bold..

when i am using this font like

$pdf->SetFont("ArialMT", "", 22);

then i got error like..

TCPDF ERROR: Could not include font definition file 

when i saw the font folder of TCPDF library then i could not see this type of font..

how to install this font in TCPDF to solve the error and get effect of this font??

please help it is urgent..

thank you in advance..

i found one solution that in

"fonts/utils/ttf2ufm.exe"
then run following to command
1)$ ttf2ufm -a -F myfont.ttf 
and
2)$ php -q makefont.php myfont.ttf myfont.ufm 
first command is successfully executed but 2nd is not executing in windows command promt so tell me what i have to do for php file as you specify in "comici.php"..
Denish
  • 2,800
  • 2
  • 23
  • 33

4 Answers4

0

Have you tried adding the font first?

$pdf->AddFont("ArialMT", "", 22);

If that does not work you can include the font in the library by using the command

$fontname = TCPDF_FONTS::addTTFfont(FCPATH.'/assets/css/fonts/ArialMT.otf');

For that you need to have the "otf" or "ttf" version of the font and set the correct directory.

For example I am using:

$fontname = TCPDF_FONTS::addTTFfont(FCPATH.'/assets/css/fonts/arialunicode050418/ArialUnicodeMS.otf');
// This should be ran only once to include the font. You can comment it afterwards.

    $pdf->AddFont('ariaunicodems', '', 10, '',false);
    $pdf->SetFont('ariaunicodems', '', 10, '',false);

You can print the "fontname" variable to see the correct name of the font to be added or set. It does not respond to the name of the font file.

Mitko Delibaltov
  • 486
  • 1
  • 6
  • 16
0

TCPDF have a tool(tcpdf_addfont.php) to install any new font which is located in 'your_path_to_tcpdf/tools/ ' You can use the following command to install a new font to TCPDF.

path_to_tcpdf/tcpdf/tools/tcpdf_addfont.php -i path_to_ttf/ArialMT.ttf

The code above is pretty much self explanatory. You can download the True Type (ttf) for any font easily using Google Search.

After running the above command you will get a output similar to:

>>> Converting fonts for TCPDF:
*** Output dir set to /path_to_tcpdf/tecnickcom/tcpdf/fonts/
+++ OK   : path_to_ttf/ArialMT.ttf added as arial
>>> Process successfully completed!

Now use this font in TCPDF like any other font:

$pdf->SetFont("arial", "", 22);
SumitK
  • 209
  • 2
  • 7
0

Try this

$pdf->AddFont('Comic','I');
// is equivalent to:
$pdf->AddFont('Comic','I','comici.php');

You will find tutorial here.

http://api.joomla.org/com-tecnick-tcpdf/TCPDF.html#AddFont

Rikesh
  • 26,156
  • 14
  • 79
  • 87
  • i found one solution that in "fonts/utils/ttf2ufm.exe" then run following to command 1)$ ttf2ufm -a -F myfont.ttf and 2)$ php -q makefont.php myfont.ttf myfont.ufm first command is successfully executed but 2nd is not executing in windows command promt so tell me what i have to do for php file as you specify in "comici.php".. – Denish Apr 28 '11 at 05:28
  • I got the problem. I was not able to execute my php command. To execute php command i edited my system variable path in my case it was C:\wamp\bin\php\php5.2.9. then i was able to execute the php command. And repeated the same procedure again.. And it worked. – Denish Apr 29 '11 at 12:18
0

You only have to create the font file once with TCPDF. This can be done, for example, with a separate PDF script. It is important to know the exact path of the original ttf and, if necessary, to place it in the appropriate folder on the server.

TCPDF_FONTS::addTTFfont('File path to the ttf file.', 'TrueTypeUnicode', '', 32);

For all commands and details see: https://stackoverflow.com/a/70337995/2320007

Sarah Trees
  • 822
  • 12
  • 28