Wednesday, March 8, 2017

Cyrillic letters not displaying in PDF generated by pdftk

The problem is that Cyrillic letters not displaying in PDF form created with pdftk, specifically using mikehaertl/php-pdftk package:

MacOS Google Chrome latest (56.0.2924.87 (64-bit)

When clicked, the symbols are displaying:

In Windows 10 Acrobat Reader similar file looks like this:

Windows 10 Acrobat Reader Cyrillyc symbols not displaying correctly

Here is the code:

$pdf = new \mikehaertl\pdftk\Pdf(public_path("demo_form_template.pdf"));

$values = [
  "name" => "МНОГОКРАТНАЯ",
  "address" => "English text",
];

$pdf->fillForm($values)
    ->needAppearances()
    ->saveAs(public_path('demo_form_filled.pdf');

To summarise, when opened in

  • MacOS Google Chrome - displays not correctly
  • MacOS Acrobat Reader - displays OK
  • Windows 7 Acrobat Reader - displays OK
  • Windows 10 Acrobat Reader - displays not correctly
  • Ubuntu Acrobat Reader - displays not correctly

Any ideas? Should I consider another solution to generate PDFs? Or may be consider fpdf or other?



via Petr Reshetin

Advertisement