Unicode Usage Fill forms with multilingual text and encoding
While all SetaPDF components accept UTF-8 values as their standard encoding the glyphs have to be converted to a font specific encoding to render them.
By default the SetaPDF-FormFiller component uses the pre-defined font in the PDF form to render a field appearance. Depending on the language it may be possible that a pre-defined font is not able to display a specific glyph. This manual will show possible workarounds for these situations.
A simple solution to support unicode values is to instruct the Reader application to re-render the form field appearances at opening time. This flag could be simply set with the setNeedAppearances() method:
Set the NeedAppearances flag.
This flag indicates the viewer to re-render the form field appearances.
- $needAppearances : boolean
The NeedAppearances flag status
Whether this flag is set, can be checked with the isNeedAppearancesSet() method.
Beside rendering the appearance by the Reader application it is possible to provide a font, that covers all used glyphs, which should be used to render the appearance.
A font is represented by a font object that could be created manually or by a TTF file. It is also possible to adjust the base encoding automatically, so that the used glyphs will be defined automatically.
$font = SetaPDF_Core_Font_TrueType::create( $document, 'DejaVuSansCondensed-Oblique.ttf', SetaPDF_Core_Encoding::WIN_ANSI, 'auto' ); $field = $fields->get('Name'); $field->setAppearanceFont($font); $field->setValue('Mr. Úmśęnłasdí');
An online-demo is available here.