Fill Pdf Form in Ruby using pdf-form gem -
i want programmatically fill pdf using pdf-form gem
i able read fields using following code:
require 'pdf_forms' pdftk = pdfforms.new('/usr/local/bin/pdftk') fields = pdftk.get_fields('*/desktop/sample_pdf.pdf') f in fields print f.to_s end
but when tried fill pdf provide synthax, created empty, not openable pdf.
pdftk.fill_form '/path/to/form.pdf', 'target.pdf', ['value name'] => 'value inserted'
does know working solution?
thanks in advance!!!
additional information:
- the fields of pdf following: name, address, dropdown1, dropdown2, dropdown3, check box4, check box1, check box3, check box2, text5, button7, text6, group6, %
- i tried filling 1 field:
pdftk.fill_form 'sample_pdf.pdf', 'sample_pdf_filled.pdf', {["name"]=>"value inserted"}
the result: have pdf "sample_pdf_filled.pdf", cannot open, because it's empty. thought problem form-filling, seems, pdf not created correctly.
note: working on mac (unix)
has solution?
method #fill_form
defined this:
def fill_form(template, destination, data = {}, fill_options = {})
you example produce this:
irb(main):001:0> { ['value name'] => 'value inserted' } => {["value name"]=>"value inserted"}
the data supposed hash. if want specify key space can use this: :'value name'
.
irb(main):002:0> { :'value name' => 'value inserted' } => {:"value name"=>"value inserted"}
Comments
Post a Comment