3

I have an application when customer is registering and when he complete the registration he's got filled 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 checkboxes. I have 2 checkboxes which customer can choose his gender. I'm trying to check it with this code:

   fill "topmostSubform[0].Page2[0].Antragst_Anrede[0]", "Male"
   fill "topmostSubform[0].Page2[0].Antragst_Anrede[1]", "Female"

But this not works. I can't find solution for this problem... Could somebody help me?

Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133

2 Answers2

6

See the following issue from the pdf-forms Github:

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 display all the form fields in the PDF. For the checkbox field in question (identified by FieldName), it should list the options available as a FieldStateOption. In my case, I had 'Off' and 'Yes' as FieldStateOptions, so calling

fill :AwesomeField, 'Yes'

resulted in AwesomeField being checked.

jorth
  • 76
  • 2
  • 4
1

I had the same problem. My pdf didn't respond to 'Yes', but it does check the box when I feed it an integer: 0 for unchecked, 1 for checked.

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