I'm trying to write a PHP-script to fill a form with data from an array.
This works mostly fine. Except that PDFTron encodes my strings so that e.g. 'Älli älä jätä' becomes ' lli l j t'.
I tried disabling read-only from the text-fields to see if manually writing some text would work - that it did.
I also tested generating the PDF with a different tool (PDFTK) - this too produced a desired PDF with Scandic letters.
<?php
require_once './lib/pdftron/PDFNetPHP.php';
PDFNet::Initialize();
/**
* @var PDFDoc
*/
$doc = new PDFDoc('./test.pdf');
$field = $doc->GetField('value');
$field->SetValue(utf8_encode('Älli älä jätä'));
$doc->RefreshFieldAppearances();
$doc->FlattenAnnotations();
$buffer = $doc->Save(SDFDoc::e_linearized);
header("Content-type:application/pdf");
header('Content-Length: ' . strlen($buffer));
echo $buffer;
Ok. So the problem doesn't seem to be with PDFTron, but with Indesign which embeds a broken font.
When I opened the PDF-document in Adobe Acrobat I was able to edit the properties for the text-field and therefore change the font 'TimesNewRomanPSMT' to 'Times New Roman' which fixed the problem.