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

I'm attempting to populate PDF form fields using CAM::PDF. I'm not getting very far. I immediately get the following error:
Could not find resource /CourierNewPSMT while preparing form field
I dug through the source and I believe I need to call addFont(page, fontname, fontlabel, [fontmetrics]). The module docs state that you must call addFont for all but the 14 core fonts. I don't know what to pass to this method. Does anyone have experience with this? Is there a better/alternate method? Thanks for your help.
use strict; use warnings; use CAM::PDF; my $infile = 'input.pdf'; my $outfile = 'output.pdf'; my $pdf = CAM::PDF->new($infile) or die 'wtf'; my @FIELDS = $pdf->getFormFieldList(); $pdf->fillFormFields($FIELDS[9] => 'test'); $pdf->cleanoutput($outfile);
I also tried running this code, although it is labelled for internal use only:
$pdf->_buildNameTable(1); my $properties = $pdf->{Names}->{1}; use Data::Dumper; print Dumper($properties); __END_- $VAR1 = { 'TT2' => bless( { 'gennum' => '0', 'value' => '39', 'type' => 'reference', 'objnum' => '8' }, 'CAM::PDF::Node' ), 'TT0' => bless( { 'gennum' => '0', 'value' => '22', 'type' => 'reference', 'objnum' => '8' }, 'CAM::PDF::Node' ), 'TT1' => bless( { 'gennum' => '0', 'value' => '32', 'type' => 'reference', 'objnum' => '8' }, 'CAM::PDF::Node' ) };

Replies are listed 'Best First'.
Re: Filling PDF forms using CAM::PDF
by Anonymous Monk on May 30, 2008 at 06:36 UTC
    use list listfonts.pl and getpdffontobject.pl
        I don't see CourierNewPSMT