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?

+3


source to share


2 answers


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.

+5


source


I had the same problem. My pdf didn't respond with "Yes", but it checks the checkbox when I feed it an integer: 0 for unchecked, 1 for checked ones.



Example of my controller: "F [0] .P1 [0] .FieldName [0]" => 1

+1


source







All Articles