Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

converting pdf form to pdf document

by jonnyfolk (Vicar)
on May 30, 2008 at 17:22 UTC ( #689283=perlquestion: print w/ replies, xml ) Need Help??
jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:

I'm using CAM::PDF to generate a completed pdf form, following node: Filling out PDF forms with data from DBI? However to send it I want to remove the editable fields and convert it into a pdf document. Can anyone help me to do this, please?
#!/usr/bin/perl # pdf-filler-test.pl 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(); # foreach ( @FIELDS ) { my $fieldnum = $_; $pdf->fillFormFields($_ => $fieldnum); } $pdf->cleanoutput($outfile);
Update: I used the following code to achieve this:
$pdf->clearAnnotations(); $pdf->cleanoutput($outfile);

Comment on converting pdf form to pdf document
Select or Download Code
Re: converting pdf form to pdf document
by zentara (Archbishop) on May 30, 2008 at 18:22 UTC
    Just a quick glance at the CAM-PDF examples, especially rewritepdf.pl, shows an option
    -C --clearannots remove all annotations (including forms)
    I don't know if that will do the trick, but you might want to look at the examples. The man pages also talk about $self->clearFormFieldTriggers(fieldname, fieldname, ...)

    I'm not really a human, but I play one on earth CandyGram for Mongo

      Hi,

      Thanks very much for your input - you were bang on the money!

      I've annotated the code in the OP for clarity.

      The only reservation I have is that in one set of form fields the input text is right justified whereas that is ignored on using the clearannots, leaving the layout slightly deficient. I suppose that the right justification is in itself an annotation - can I exempt it?

      Cheers.

Re: converting pdf form to pdf document
by almut (Canon) on May 30, 2008 at 20:45 UTC

    Not a Perl solution, but if all else fails, you could try pdftk's flatten option (worked fine for me so far)

    $ pdftk filled-form-doc.pdf output flat-doc.pdf flatten

    ___

    [flatten] Use this option to merge an input PDF's interactive form fields (and their data) with the PDF's pages. Only one input PDF may be given. Sometimes used with the fill_form operation.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://689283]
Approved by MidLifeXis
Front-paged by MidLifeXis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-08-01 22:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (51 votes), past polls