jkraemer / pdf-forms

Fill out PDF forms with pdftk (http://www.accesspdf.com/pdftk/).
MIT License
287 stars 73 forks source link

Cant fill field names with html escape characters #65

Closed LaithAzer closed 6 years ago

LaithAzer commented 6 years ago

Firstly thanks a lot for this gem. It has been great to use.

I have a form that I am trying to fill using pdftk, and some of the field names are as follows:

Other Tests – one test per line, Row 15 Other Tests – one test per line, Throat

Unfortunately I cannot change the field names and pdftk doesn't seem to be able to fill them out. I also tried escaping the string, typing the actual character (en dash), but no success.. All the other fields get filled in fine but these fields I cannot seem to fill in no matter what I try..

jkraemer commented 6 years ago

Please run pdftk your-template.pdf dump_data_fields. This should give you output like:

---
FieldType: Text
FieldName: caregiver_email
FieldFlags: 0
FieldJustification: Left
---
FieldType: Text
FieldName: screening_names_of_people_assisting
FieldFlags: 0
FieldJustification: Left
---

Whatever is written in the lines starting with FieldName: is what you have to use as field name when filling out the form. If this does not work I'd appreciate access to the form in question to look into this.

LaithAzer commented 6 years ago

Hi @jkraemer.

Those are the field names I get from running that command. I figured out a workaround by renaming the pdf fields since I have access to acrobat pro, but feel free to take a look at the form in case you can figure out the issue:

http://www.forms.ssb.gov.on.ca/mbs/ssb/forms/ssbforms.nsf/GetAttachDocs/014-4422-84~1/$File/4422-84.pdf

phoet commented 6 years ago

i came accross the same issue:

---
FieldType: Text
FieldName: Straße Hausnummer
FieldNameAlt: Straße, Hausnummer
FieldFlags: 0
FieldJustification: Left

i worked around that by unescaping the entities @pdftk.get_field_names(@path).map { |name| CGI.unescapeHTML(name) }

jkraemer commented 6 years ago

Thanks, I added this to the README