Search code examples
phppdflib

Pdflib textfield in table cell - encoding breaks when losing focus


While entering text the first time it seems fine. But as soon as the textfield loses focus the encoding seems to break and remains broken when entering the field again.

Broken encoding

the following optlist was given to "add_table_cell"

fieldtype=textfield fieldname={price_5f215239aaa89} fitfield={multiline=true linewidth=1 font=1 fontsize=3 scrollable=false}

Edit

Pdflib version: 9.1.1 Font loaded with $pdflib->load_font($fontName, 'unicode', 'kerning=true embedding=true fontwarning=true');

The font is used by other elements in the Document without problems.

Font in Textflow Font in Textflow

Font in Form Field Font in Textfield


Solution

  • With PDFlib 9.1.1 you have to use a font with 8-bit encoding for a form field.

    So you should load a second font with:

    $fieldfont = $pdflib->load_font($fontName, 'winansi', 'simplefont embedding nosubsetting');
    

    Please see PDFlib 9.1.1 API Reference, chapter 4.1, table 4.2 for details on the simplefont option. Please apply the $fieldfont fonthandle to the form field option list.