jeffy has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to develop a system that will fill out a pdf form that I've been provided -- specifically the MLS property submission form. Having looked at CAM::PDF, PDF::API2 and a few others, the closest I've come up with is:

use pdftk to dump_data_fields to get a list of fields

Use PDF::FDF::Simple to create a valid FDF file appropriate to filling out the form.

Use pdftk to fill_form.

Voila. If I just had text fields, that would work. My problem is handling radio buttons. pdftk reports fields like:

FieldType: Button FieldName: MyData[0].Page2[0].Furnished[0].FurnishedYN[0] FieldFlags: 49152 FieldJustification: Left FieldStateOption: 0 FieldStateOption: 1 FieldStateOption: 2 FieldStateOption: Off --- FieldType: FieldName: MyData[0].Page2[0].Furnished[0] FieldFlags: 0 FieldJustification: Left ---

I can find no combination of field name and value that will cause the Right Thing to happen. The FDF file looks like what I expect, but pdftk doesn't seem to be able to fill in the radio button.

One more note: my pdftk *might* be broken. It has a generate_fdf operation, for instance, which might have skipped the current Perl step, but this operation seems to be missing in my installation. It seems barely possible that my version is old (though this is the most recent package for CentOS) and doesn't support a version of PDF that has radio buttons or something.

$ pdftk --version pdftk 1.12 a Handy Tool for Manipulating PDF Documents Copyright (C) 2003-04, Sid Steward - Please Visit: www.pdftk.com

Any help will be much appreciated. I'm not married to any aspect of my current solution. The final tasks should work on Linux, but one-time things (like perhaps creating an FDF template that I would substitute into, perhaps) can happen on OSX or even a borrowed windows box if needed.

Replies are listed 'Best First'.
Re: Extracting pdf form fie ld names and appropriate valuesm
by marto (Cardinal) on Mar 16, 2010 at 08:00 UTC