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.

Before you can use UTF-8, you have to install at least one Unicode font in the font/unifont directory. Some free font packages are available for download (extract them into font/unifont):

Fonts from the DejaVu family:

Fonts from the GNU FreeFont family:

You can also make your own fonts by pointing your browser to font/unifont/makefonts/makefonts.php and following instructions (if you're on Windows).

Then, to use a Unicode font in your script, pass true as the fourth parameter of AddFont().

Note: this class requires the mbstring extension.


This example uses the DejaVu Sans Condensed font to display some Unicode strings. Be sure to install the font in the font/unifont directory first.

$pdf = new sFPDF();

// 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 17 KB.');

View the result here.