PDF File Information

The files here demonstrate how a web site (or other program) can generate a PDF file. There are two ways to do this.

The first way involves generating an "FDF stream", or "FDF file", which contains the location of a real PDF file which contains empty fields needing to be filled out (created with the full Adobe Acrobat program) and a list of the data to be placed in these fields.

Note that this requires Adobe Acrobat Reader to work correctly (which is free.) Other programs (such as "xpdf" for *nix systems) may not be able to handle this format.

The form I'm using as a sample is the Web Hosting Information Form used by, who was my employer at the time I wrote this stuff. If you play with the form, the AS/400 account and location numbers should be strings of up to nine digits (although I don't think the script does any checking on this, since this was meant to be a simple proof-of-concept to show somebody at KUA how it was done.)

webinfo.html A form to input data for... Perl script to read info from "webinfo.html" and output an FDF stream containing the URL of webinfo.pdf (below.) Clicking this link is kinda useless- it will run the script with no input and generate an empty form.
webinfo.pdf A PDF file which contains empty fields which are filled in by the data values in the FDF stream.
webinfo.txt Text (viewable) copy of ""
webinfo-fdf.txt Text (viewable) copy of what an FDF stream looks like inside (it's not complicated at all.)

The other option is to generate a PDF file entirely from scratch, obviously inserting the data wherever you want (as read-only items.) This relies on server-side software which knows how to generate PDF, such as the PDF::API2 Perl module (available through CPAN.) Since most of what I've done over the past few years has been written in Perl, this is what I used here.

Note that this is NOT a full CGI application, this is a simple command-line program to write out a PDF file. The idea is to figure out ahead of time the actual programming needed to "draw" the form you want to use, and then add the field data to it as needed. I may flesh this out at some time in the future, but this script should have enough to get you started.

The script refers to "lucon.ttf", which is included with Microsoft Windows 98, ME, 2000, and XP. The actual file is NOT included here for copyright reasons. Either find your own copy, use a different TTF file (and edit the script accordingly,) or just comment those four lines out and skip that portion of it.

fonts.txt Sample perl script showing the basics of how to generate a PDF file from scratch. This is the script I used to teach myself how to use the PDF::API2 module. You will probably want to rename this to "" if you're going to play around with it.
testing.pdf The PDF file generated by this script. It may be interesting to look at by hand, because it's not compressed- the only parts of the file which are not directly human-readable are a few binary objects, the rest of the file is easy to read.

[hacker emblem] Copyright 2002-2005 John M. Simpson <>
Last updated 2005-04-05