The Perl You Need to Know Part 16: A Simple Approach to PDF - Page 1
August 28, 2000
|
Adobe's Portable Document Format, or PDF, has become something of a
standard for storing and forwarding documents destined for the printed page.
PDF documents retain their formatting whether printed at home on an inkjet
printer or published and bound at the neighborhood print shop, and the wide
adoption of this format makes PDF a good choice for delivering data intended
for hardcopy. Most web-based
Perl scripts are built to deliver
results in
HTML format, aimed at the web browser; in
some cases, though, the option to deliver result data in PDF format may be
a real boon to visitors of your site. This month we'll look at one rather
simple way of bringing PDF capability to your Perl scripts.
|
The case for PDF
Since the dawn of the printing machine, printing documents has been a pain
in the backside for one reason or another. In Gutenberg's day, it took hours
or days to simply find and set each cast block needed to imprint each letter
on the page. By the 1980's, these same hours were devoted to re-aligning the
printer paper in the tractor feed mechanism so that it would stop feeding
through crooked. This nightmare was followed by a long round of tearing off
the strips of feed holes without ripping into the printed area. Not
coincidentally, the confetti industry experienced an economic boom during
these years. And that's just the hardware side of things.
Software applications for word processing and desktop publishing have fought
an uphill battle against consistency -- import your document from one
application to another, and watch how it prints completely differently.
Even within the same software, on different computers or printers, one never
knew for sure exactly how a document would print.
Adobe saw a wide-open market in this gap of frustration, and so was born the
Portable Document Format, PDF, a variety of compressed Postscript, an
interpreted language widely used in "professional" printers. Adobe
evangelized their format by opening the specification, encouraging
developers, and freely distributing the Adobe Acrobat software which can
read and print PDF files. The allure of PDF is its consistency -- an author
can create a document in PDF and be assured that it will look and print
exactly the same on any system or printer which can render the PDF format.
Consequently, the web is awash in printable publications from brochures to
entire books stored in the PDF format.
Our premise in this column is that your web applications, too, may find it
useful to deliver results in PDF format, in addition to or instead of
traditional HTML.
Suppose your Perl script generates a report of inventory from a database --
if you want to print this report and send a printable version to 100 other
employees, it may be far easier to generate and pass around a PDF version
of the report than ask people to attempt the unreliable art of printing web
pages from a browser.
Imagine a web site that delivers articles, perhaps news stories or works of
fiction, which readers may well want to print. You could leave them to
struggle with printing from their browser, which often results in strange
quirks on the page, or provide a PDF version of articles on your site.
The fact is, many Perl scripts deliver dynamic content which visitors may
appreciate having in PDF format. Adding this capability is a nice feature,
and for many cases, not terribly difficult.
Contents:
Skipping the Learning Curve
The Kindness of Strangers: HTMLDOC
HTML Becomes PDF
Enter the Perl
Conclusion
The Perl You Need to Know
Skipping the Learning Curve - Page 2
|