Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Filling PDF Form Checkboxes

by Anonymous Monk
on Jul 29, 2020 at 14:47 UTC ( #11119986=note: print w/replies, xml ) Need Help??


in reply to Filling PDF Form Checkboxes

follwing code works for me though there is an error message "Unknown resource key 'Encoding' in form field dictionary at /usr/local/share/perl/5.26.1/CAM/PDF.pm line 2914."
#!/usr/bin/perl -w use strict; use CAM::PDF; my $pdf = CAM::PDF->new('tenant.pdf') or die "Could not open PD +F ($!)!"; my @fields = $pdf->getFormFieldList(); foreach my $field ( @fields ) { if ($field =~ /Female/) { my $ff_obj = $pdf->getFormField($field); $ff_obj->{value}->{value}->{AS}->{value} = "On"; } else { $pdf->fillFormFields($field => $field); } } $pdf->cleanoutput('afilled.pdf');

Replies are listed 'Best First'.
Re^2: Filling PDF Form Checkboxes
by Anonymous Monk on Aug 03, 2020 at 18:20 UTC

    Upon further research on the checkbox issue, I just realized that {AS}->{value} is where you can control the option

    In the same PDF file that I worked in above instance, there is another kind of check box in the dictionary that is using indirectObject

    which points to a parent dictionary which has {AS}->{value}. In this instance {AS}->{value} was set "Off" initially but I had to use {D}->{value} which is inside of the same parent dictionary to set {AS}->{value} to turn check box on,in my case, it is "Yes_2", that is {AS}-{value}="Yes_2"

Re^2: Filling PDF Form Checkboxes
by Anonymous Monk on Jul 29, 2020 at 15:12 UTC

    I have used following improved code to mark my checkbox in pdf

    #!/usr/bin/perl -w  use strict; use CAM::PDF;  my $pdf = CAM::PDF->new('tenant.pdf') or die "Could not open PDF ($!)!";  $pdf->getFormFieldList();  my $field ="Female";  my $ff_obj    = $pdf->getFormField($field);        $ff_obj->{value}->{value}->{AS}->{value} = "On";   $pdf->cleanoutput('afilled.pdf');

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11119986]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2021-06-16 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (74 votes). Check out past polls.

    Notices?