0

I'm writing a PDF exporter for a Slovak web page. My DB is UTF-8 encoding. Some characters from the DB are converted correctly, some are not, here is the example: input from DB: ôňúäéíáýážťčššľĽŠČĎŽŇÁÍÚĹŤÉŽŹÝ output in PDF: ônúäéíáýážtcššlLŠCDŽNÁÍÚLTÉŽ´ZÝ font used: Helvetica

Basic code for PDF write:

$pdf = new Fpdi('P', 'mm', 'A4');
...
$pdf->SetX(14);
$pdf->write(40, iconv('UTF-8', 'windows-1252//TRANSLIT//IGNORE', $invoiceDetails->getCompanyName()));
...
// return output for preview
return $pdf->Output('I');

I've tried at least 10 encodings but none of them was able to give me all characters.

Thank you for your help.

Jozef Kétyi
  • 147
  • 2
  • 11

1 Answers1

1

The standard fonts in FPDF only support cp1252 (aka windows-1252) encoding. So changing the encoding of your text to any other encoding doesn't change a thing.

You should prepare a special font with an ISO-8859-2 encoding and convert your text to this encoding before passing it to the methods of FPDF. The whole font generation process is described here.

Jan Slabon
  • 4,736
  • 2
  • 14
  • 29