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.