I want to programmatically fill a pdf using pdf-form gem
I was able to read the fields using the following code:
require 'pdf_forms'
pdftk = PdfForms.new('/usr/local/bin/pdftk')
fields = pdftk.get_fields('*/Desktop/sample_pdf.pdf')
for f in fields
print f.to_s
end
But when I tried to fill the Pdf with the provide synthax, I created only an empty, not openable pdf.
pdftk.fill_form '/path/to/form.pdf', 'target.pdf', ['Value Name'] => 'Value to be inserted'
Does anybody know a working solution?
Thanks in advance!!!
Additional Information:
- the fields of the pdf are the following: Name, Address, Dropdown1, Dropdown2, Dropdown3, Check Box4, Check Box1, Check Box3, Check Box2, Text5, Button7, Text6, Group6, %
- I tried it with filling just one field:
pdftk.fill_form 'sample_pdf.pdf', 'sample_pdf_filled.pdf', {["Name"]=>"Value to be inserted"}
The result: I have an pdf "sample_pdf_filled.pdf", which I cannot open, because it's empty. I thought my problem is the form-filling, but it seems, that the pdf is not created correctly.
Note: I am working on a mac (unix)
Has anybody a solution?