Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Filling out PDF forms with data from DBI?

by Thelonius (Priest)
on Jun 22, 2006 at 04:44 UTC ( [id://556830]=note: print w/replies, xml ) Need Help??


in reply to Filling out PDF forms with data from DBI?

You can easily create an FDF file with the data for the fields. For example, using your example file, you can create fw9a_data.fdf:
%FDF-1.2 1 0 obj<</FDF<< /Fields[ <</T(c1-1)/V/Yes>> <</T(c1-2)/V/Off>> <</T(c1-3)/V/Off>> <</T(c1-4)/V/Off>> <</T(c1-5)/V/Off>> <</T(f1-1)/V(An individual name)>> <</T(f1-2)/V(Here is where the business name would go)>> <</T(f1-3)/V(Something something)>> <</T(f1-4)/V(111 somewhere st)>> <</T(f1-5)/V(Gotham City, MA)>> <</T(f1-6)/V(Requestor's name\r111 somewhere St.\rGotham City, MA)>> <</T(f1-7)/V(List_account_numbers)>> <</T(f1-8)/V(3)>> <</T(f1-9)/V(1)>> <</T(f1-10)/V(4)>> <</T(f1-11)/V(1)>> <</T(f1-12)/V(5)>> <</T(f1-13)/V(9)>> <</T(f1-14)/V(2)>> <</T(f1-15)/V(6)>> <</T(f1-16)/V(5)>> <</T(f1-17)/V(9)>> <</T(f1-18)/V(8)>> <</T(f1-19)/V(7)>> <</T(f1-20)/V(6)>> <</T(f1-21)/V(5)>> <</T(f1-22)/V(4)>> <</T(f1-23)/V(3)>> <</T(f1-24)/V(2)>> <</T(f1-26)/V(1)>> ] /F(fw9a.pdf)>>>> /ID[<B97089A55B4A6C612CDC01693E405875> <5E6E5A68A50C834B953FA17874436B87>] endobj trailer <</Root 1 0 R>> %%EOF
Using the free Acrobat Reader, I copied fw9.pdf to fw9a.pdf, filled in a few fields, then used the menu command "Document|Forms|Export Data from Form..." to create "fw9a_data.fdf". I have thrown in a few line breaks to make it readable.

If you give the user the two files "fw9a_data.fdf" and "fw9a.pdf", they can then open this in Acrobat or Acrobat Reader. (E.g., by double-clicking fw9a_data.fdf)

If you want to just create a printable PDF, you could use the command-line pdftk utility.

pdftk fw9a.pdf fill_form fw9a_data.fdf output fw9print.pdf
It's possible that CAM::PDF may be able to do this, but I haven't gotten it to install properly. In the merged file, the form data is in there twice, once as form data and once as print instructions, e.g. for the name/address field, pdftk creates this object which will tell a PDF renderer how to print the data:
10 0 obj <</Matrix [1 0 0 1 0 0] /Subtype /Form /Length 150 /Resources <</Font <</HeBo 2 0 R >> /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] >> /FormType 1 /BBox [0 0 179.66 37] /Type /XObject >> stream /Tx BMC q 1 1 177.66 35 re W n 0 0 0.50196 rg BT /HeBo 9 Tf 10.71 TL 2 + 27.34 Td (Requestor's name)Tj (111 somewhere St.)' (Gotham City, MA) +' ET Q EMC endstream endobj

The output from pdftk is a PDF file that is printable, but you can't edit and resave the data in the free Adobe Reader. (You might be able to edit it in full Adobe.) The IRS forms are editable in Adobe Reader because the IRS paid for an expensive Adobe product that signs the file. (See http://seclists.org/lists/vulnwatch/2003/Jan-Mar/0103.html and http://weblog.infoworld.com/udell/2003/09/04.html.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-06-17 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.