pdffillerjs / pdffiller

Take an existing PDF Form and data and PDF Filler will create a new PDF with all given fields populated.
MIT License
286 stars 113 forks source link

Some special characters are rendering to pdf file, some are not #59

Open maximilianschmidt opened 7 years ago

maximilianschmidt commented 7 years ago

Hi there,

i am encountering a strange problem.

When filling a PDF with strings containing special characters, some are displayed in the rendered form and some are not.

For example, the string: "Wypełnić Pełnomocnictwo, podpisać i wstawić pieczątkę." renders to "Wypełni Pełnomocnictwo, podpisa i wstawi piecz tk ."

The "ć, ą and ę" are missing and are rendered as a blank or as a square to the PDF, but the "ł" is rendered correctly.

Now the funny thing is, when i open the rendered pdf in adobe, edit the font of the formfield under Settings -> Appearance to Helvetica or Times or whatever, it doesnt really matter, the characters are all rendered correctly ("ć, ą and ę" are showing up in the form field).

Even if i already set the font of the field to Helvetica (characters dont show up), save it, render the document, switch it to Times (characters do show up) and then back to Helvetica (characters also do show up).

Anyone got an idea?

maximilianschmidt commented 7 years ago

ok, nevermind. found out the problem is with adobe either not showing the characters or using a wrong font encoding. apparently nothing to do with pdffiller.

maximilianschmidt commented 7 years ago

actually, this is a problem with pdftk and some special characters (see https://github.com/mikehaertl/php-pdftk/issues/4). basically we need an option to call fillFormWithOptions with pdftk's need_appearances argument (see here). keep in mind that it wont work with the option flatten set to true

MichaelIT commented 7 years ago

@maximilianschmidt tks, It work when filling chinese characters

6112115 commented 5 years ago

To add to this, I checked the FDF file output, and that is where the issue is. This is nothing to do with pdfkit inserting the data. If you open index.js in this project and comment out the unlink line, and inspect the resulting fdf file, the data is incorrect before even inserting into the PDF.

The FDF generator is utf8-fdf-generator. Maybe its time this project used a more modern FDF generator?

bin-sun commented 5 years ago

@MichaelIT Can you tell me how to fill chinese charachters? I'll be very grateful to you.