Xinel
Xinel

Reputation: 129

TFPDF Lithuanian letters

I have a problem with lithuanian letters like ąčęėįšųūž. For that reason I use tfpdf and font DejaVu. When I get content from txt file, everything is fine but I give content just simply, then I get "????". Header charset is set utf-8.

ob_start();
require('../fpd/tfpdf.php');

$pdf = new tFPDF();
$pdf->AddPage();

// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',10);

// Load a UTF-8 string from a file and print it
$txt = file_get_contents('../fpd/HelloWorld.txt');
$pdf->Write(8,$txt);
$pdf->Ln(10);
$txt1 = "ąčęėįšųž";
$pdf->Write(8,$txt1);

$pdf->Output('filename1.pdf', 'I');

ob_end_flush(); 

Upvotes: 2

Views: 839

Answers (1)

Jan Slabon
Jan Slabon

Reputation: 5058

You do not need to set the header to UTF-8 but your editor have to be configured to use UTF-8. To verify that this is the issue, open the PHP file in e.g. Notepad++, click on "Encoding" and check the current encoding. You may convert it to UTF-8 (without BOM!!) in the same step and try again.

Upvotes: 0

Related Questions