Mr.Web
Mr.Web

Reputation: 7154

PDFI Library utf-8 encoding

I've installed PDFI library in my PHP application and it works fine.

The only problem I have is setting the encoding. I'm in Italy and my App should use UTF-8 encoding, but I can't find the option.

This is my code:

    $pdf = new FPDI();
    $pdf->AddPage();
    $pdf->setSourceFile("Modulo_Tesserato.pdf");
    $tplIdx = $pdf->importPage(1);
    $pdf->useTemplate($tplIdx, 0, 0, 210);

    foreach ($args as $txts => $txt) {
        $pdf->SetFont('Helvetica');
        $pdf->SetTextColor(0, 0, 0);
        $pdf->SetXY($txt['x'], $txt['y']);
        $pdf->Write(0, trim($txt['testo']));
    }       

    $pdf->Output();

(In the foreach I pass the array with the text lines to be written)

This is the result of my PDF:

enter image description here

It should be showing ì instead of that ì symbol and può instead of può

Can you help me in setting the encoding?

Upvotes: 0

Views: 471

Answers (1)

silkfire
silkfire

Reputation: 25955

Try converting your strings to the right encoding by using utf8_decode().

Upvotes: 1

Related Questions