Checkbox check with pdftk library in Ruby on Rails
I have an application where a client registers and when he completes registration he received a completed pdf template. To fill pdf templates I use this gem:
https://github.com/jkraemer/pdf-forms
But with this library I don't know how to check the checkboxes. I have 2 checkboxes that the client can choose for their gender. I am trying to test it with this code:
fill "topmostSubform[0].Page2[0].Antragst_Anrede[0]", "Male"
fill "topmostSubform[0].Page2[0].Antragst_Anrede[1]", "Female"
But it doesn't work. I can't find a solution to this problem ... Can anyone help me?
source to share
See the following question from Github pdf forms:
https://github.com/jkraemer/pdf-forms/issues/22
In short, it depends on how the PDF is configured. At the terminal
pdftk mypdf.pdf dump_data_fields
should render all form fields to PDF. For the corresponding checkbox field (named FieldName), it must specify the options available as FieldStateOption. In my case, I had "Off" and "Yes" as FieldStateOptions, so the call
fill :AwesomeField, 'Yes'
led to checking AwesomeField.
source to share