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.


In reply to Extracting pdf form field names and appropriate values by jeffy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.