Adobe's Portable Document Format (PDF) provides a popular way to get a consistent look, both on screen and when printed, for documents. This chapter shows how to dynamically create PDF files with text, graphics, bookmarks, and more.
Dynamic construction of PDF files opens the door to many applications. You can create almost any kind of business document, including form letters, invoices, and receipts. Most paperwork that involves filling out a paper form can be automated by overlaying text onto a scan of the paper form and saving the result as a PDF file.
PHP has several libraries for generating PDF documents. This chapter shows how to use the popular pdflib extension. One drawback of pdflib is that it is not an open source library. Its Aladdin license allows free personal and noncommercial usage, but for any commercial use you must purchase a license. See http://www.pdflib.com for details. Open source alternatives include clibpdf (http://www.fastio.com) and the interesting FreeLibPDF (http://www.fpdf.org), which is written in PHP.
Since pdflib is the most mature and has the most features, that is the library we cover in this chapter. The basic concepts of the structure and features of a PDF file are common to all the libraries, though.
Copyright © 2003 O'Reilly & Associates. All rights reserved.