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

I have a hidden form field in a PDF file, that contains a default value (a site ID), so when the form is submitted via email the default value is passed. What I need to do is write a little program that will change the default value of the hidden field to a different site ID (of which I have a couple of hundred) and save the PDF file with a new name (so it can be emailed to all the users at that site). CAM::PDF is the only module that I have been succesful with in accessing form values, but the hidden form field is giving me trouble as it won't let me override the default value.

I read the file in successfully, grab the form field object, set the value, and save the PDF file. When I open the newly saved PDF file it is the old default value, not the new value. I can use the same process and set visible form fields and they work OK. Does anyone have any suggestions that might help me get over the hump with this issue?

g_White

Replies are listed 'Best First'.
Re: Using CAM::PDF to change a form value
by starX (Chaplain) on Aug 27, 2007 at 18:05 UTC
    Taking a look at the documentation for CAM::PDF, it looks like a lot of those functions are labeled as being for internal use only. Maybe you could post some code so we could take a look at how you're trying to do this?
      Extremely basic code
      #!/usr/bin/perl use strict; use CAM::PDF; my $pdf = CAM::PDF->new('input-form.pdf'); $pdf->fillFormFields( 'site' => 'newsitename'); $pdf->cleanoutput('changed-form.pdf'); print "Done\n";
      g_White
        Out of curiosity, have you tried calling output() separately?
        g_White, Did you figure out a solution? My form fields are supposed to be visible. I can open the new/modified/updated pdf in Adobe. I have to click on the field for the field data to become visible. I can also print out the form fields via printer options, but printing the whole document the updated/modified fields are always blank. The fields that have not been modified are fine and show up accordingly.