We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fill_form
I'm trying to programmatically fill out this PDF: http://www.irs.gov/pub/irs-pdf/f1065sk1.pdf
and I'm seeing if your gem can help me. Here's the test script I'm using:
#!/usr/bin/env ruby require 'pdf_forms' require 'pry' pdftk = PdfForms::PdftkWrapper.new('/usr/local/bin/pdftk') pdf = PdfForms::Pdf.new('2014_k1.pdf', pdftk) field_names = pdf.fields.map(&:name) field_values = field_names.map do |name| ret = {} ret[ name ] = name ret end pdftk.fill_form '2014_k1.pdf', 'filledout_k1.pdf', field_values
A PDF named filledout_k1.pdf is written to disk, but it doesn't have any fields filled out.
filledout_k1.pdf
Do I need to convert the PDF to some other format to be able to fill it? I haven't done much with PDFs so I'm not sure how to go about it.
The text was updated successfully, but these errors were encountered:
In your code field_values is an array of one-element hashes, but fill_form takes a single hash holding the data to fill in.
field_values
I think this
field_values = Hash[ pdf.fields.map{|f| [f.name, f.name]} ]
does what you want.
Sorry, something went wrong.
That worked, thanks for pointing out my oversight @jkraemer and nice work on this gem!
No branches or pull requests
I'm trying to programmatically fill out this PDF: http://www.irs.gov/pub/irs-pdf/f1065sk1.pdf
and I'm seeing if your gem can help me. Here's the test script I'm using:
A PDF named
filledout_k1.pdf
is written to disk, but it doesn't have any fields filled out.Do I need to convert the PDF to some other format to be able to fill it? I haven't done much with PDFs so I'm not sure how to go about it.
The text was updated successfully, but these errors were encountered: