User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive

Article Index

Download TCPDF

As mentioned earlier, TCPDF v2.5.000 supplied in Joomla! 1.5.7 doesn't provide an option not to embed the complete font file. Fortunately the newer version of TCPDF does. So our plan is basically to replace the version in Joomla! with the latest version of TCPDF and make it to work with Joomla!.

Please head for the official TCPDF Web site and download the latest version. Uncompress the ZIP file into your local hard drive. A folder named tcpdf will be created and contain TCPDF source codes.

Create Font Script

Even though we don't want TCPDF to put the whole font file in the PDF, we still have to let it include some font metrics information. You will need to run a couple of tools included in the TCPDF release package to create a php script that contains some essential font information.

In order to allow Chinese PDF to be properly displayed in Adobe Acrobat without embedding the actual font file, the font to be used must be a part of Acrobat installation already. If you check the Resource\CIDFont folder under Acrobat's installation directory, you should find several font files for Asian languages. For Traditional Chinese, Adobe Acrobat provides a AdobeMingStd-Light.otf, which is the font we use. (We assume your local machine is a Windows computer because one of the commands you have to use is a DOS program.)

Now change into the folder fonts\utils under the tcpdf folder that contains TCPDF source codes. Copy the font file AdobeMingStd-Light.otf into this folder, and rename the file to adobemingstd-light.otf. Open a DOS command prompt window, and then execute the following command to generate the font's metrics file.

D:\tcpdf\fonts\utils> ttf2ufm -a -F adobemingstd-light.otf

The command will take a short while to finish. Once it is done, you should see three more files in the same directory with filename extensions .afm, .t1a and .ufm.

Next you need to run a PHP script makefont.php. (You need PHP installed on your Windows machine, or you can copy those three files created to your server and run the following command there.)

D:\tcpdf\fonts\utils> php -q makefont.php adobemingstd-light.otf adobemingstd-light.ufm false

This creates a compressed file with a .z extension and a PHP script named adobemingstd-light.php which will be used by TCPDF to generate PDF outputs. Before the PHP script can be used, there are some modifications must be done. Please open adobemingstd-light.php in your favorite text editor, and make following changes:

  • change the font type to: $type='cidfont0';
  • set the default font width by adding the line: $dw=1000;
  • remove the $enc, $file and $ctg variables definitions
  • add the following block of text at the end of the file :
    // Chinese Traditional
    $cidinfo=array('Registry'=>'Adobe', 'Ordering'=>'CNS1','Supplement'=>0);

For modifications for other Asian languages, please refer to the document at official TCPDF site.

FaLang translation system by Faboba