Home » Php » php – TCPDF can't show cyrillic

php – TCPDF can't show cyrillic

Posted by: admin July 12, 2020 Leave a comment


I’m trying to output cyrillic in pdf with TCPDF .

I tried using, UTF-8, Windows-1251. I had changed the Unicode to FALSE and TRUE, to test, but I’m getting only? I tried with default and with font from file, but same results, and I tried using setsubsettings, again, no result. What is wrong?

How to&Answers:

Setting the font to freeserif did it for me – default/helvetica font: unreadable cyrillic characters; freeserif: readable Russian text.

// set default font subsetting mode

// set font
$pdf->SetFont('freeserif', '', 12);



Replace SetFont

$pdf->SetFont('dejavusans', '', 10);


use TFPDF instead.

Check the source here:



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