Author: Ian Back
License: LGPL


This class is a modified version of FPDF that adds UTF-8 support. Moreover, it embeds only the necessary parts of the fonts that are used in the document, making the file size much smaller than if the whole fonts were embedded. These features were originally developed for the mPDF project.

To use a Unicode font in your script, pass the font file name as third parameter of AddFont() and true as fourth parameter. The font may be located either in the font/unifont directory or directly in the system font folder (in case the _SYSTEM_TTFONTS constant is defined). The package ships with the DejaVu font family.

Note: this class requires the mbstring extension.


This example uses the DejaVu Sans Condensed font to display some Unicode strings.

// Optionally define the filesystem path to your system fonts
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/");


$pdf = new tFPDF();

// Add a Unicode font (uses UTF-8)

// Load a UTF-8 string from a file and print it
$txt = file_get_contents('HelloWorld.txt');

// Select a standard font (uses windows-1252)
$pdf->Write(5,'The file size of this PDF is only 13 KB.');

View the result here.