1

The following works fine if I only fill in the fields of the PDF (i.e. the boolean_a field is an empty list). But if I add entries to the list for checkboxes, I get the exception given below.:

field_a = [[b'Date Prepared', 'October 30, 2016']]
boolean_a = [[b'Check Box1', 'Yes']]

form = 'form.pdf'
fdf = 'temp.fdf'
output = 'output.pdf'
write_sect(field_a, boolean_a, fdf, form, output)


def write_sect(fields, booleans, fdf, form, output):

    forged_fdf = forge_fdf('', fields, booleans, [], [])

    with open(fdf, 'wb') as tmp_fw:
        tmp_fw.write(forged_fdf)

    call('pdftk "{0}" fill_form "{1}" output "{2}" dont_ask'.format(form, fdf, output))

    return

I get the following error:

Unhandled Java Exception in create_output():
java.lang.ClassCastException: pdftk.com.lowagie.text.pdf.PdfNull cannot be cast to pdftk.com.lowagie.text.pdf.PdfDictionary
   at 0x0059a84e (Unknown Source)
   at 0x0059ad42 (Unknown Source)
   at 0x005e9bd4 (Unknown Source)
   at 0x005ba4a4 (Unknown Source)
   at 0x005b2044 (Unknown Source)
   at 0x0059231e (Unknown Source)
   at 0x004723f1 (Unknown Source)
   at 0x00472045 (Unknown Source)
   at 0x004df3e2 (Unknown Source)
   at 0x004df38a (Unknown Source)
   at 0x00471e74 (Unknown Source)

1 Answers1

0

I found the problem and am leaving this post here for anyone else who encounters this same error.

This post regarding how to fill in checkboxes is not correct.

I read the comments in the actual code here and found that checkboxes are indeed handled by fdf_data_strings and not fdf_data_names.

Community
  • 1
  • 1