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?
Setting the font to freeserif did it for me – default/helvetica font: unreadable cyrillic characters; freeserif: readable Russian text.
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// set font
$pdf->SetFont('freeserif', '', 12);
Answer:
Replace SetFont
$pdf->SetFont('dejavusans', '', 10);
Answer:
use TFPDF instead.
Check the source here:
http://www.fpdf.org/en/script/script92.php
e.g.:
<?php
// 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/");
require('tfpdf.php');
$pdf = new tFPDF();
$pdf->AddPage();
// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',14);
// Load a UTF-8 string from a file and print it
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 13 KB.');
$pdf->Output();
?>