Answer the question
In order to leave comments, you need to log in
Why doesn't PDFtk display Cyrillic when filling out PDF forms?
I need to fill PDF forms with data using PHP. I'm using the mikeheartl library as a wrapper for PDFtk, but PDFtk doesn't display my data in Russian when I turn off file editing with the flatten() function.
How can I fix or work around this issue. The HTML to PDF option is not suitable.
Here is the file generation method:
private function generate($fields, $filename, $path)
{
$options = array(
'command' => "C:\Program Files (x86)\PDFtk\bin\pdftk.exe",
'useExec' => true,
);
$pdf = new Pdf($path, $options );
$res = $pdf->fillForm($fields)
->flatten() // Отключает редактирование
->compress()
->needAppearances()
->saveAs("./completed/" . $filename);
if($res === false) {
print_r($pdf->getError());
return false;
}
return $filename;
}
Answer the question
In order to leave comments, you need to log in
1.
Try adding this to your function, or else change UTF-8 to WINDOWS-1251 later.
2.
'encoding' => 'UTF-8', // option with argument
'commandOptions' => array(
'useExec' => true, // Can help on Windows systems
'procEnv' => array(
// Check the output of 'locale -a' on your system to find supported languages
'LANG' => 'en_US.utf-8',
),
),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question