05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10 CHAPTER 10<br />

PDF<br />

Adobe’s Portable Document Format (PDF) provides a popular way to get a consistent<br />

look, both on screen and when printed, for documents. This chapter shows how<br />

to dynamically create PDF files with text, graphics, bookmarks, and more.<br />

Dynamic construction of PDF files opens the door to many applications. You can<br />

create almost any kind of business document, including form letters, invoices, and<br />

receipts. Most paperworkthat involves filling out a paper form can be automated by<br />

overlaying text onto a scan of the paper form and saving the result as a PDF file.<br />

PDF Extensions<br />

<strong>PHP</strong> has several libraries for generating PDF documents. This chapter shows how to<br />

use the popular pdflib extension. One drawbackof pdflib is that it is not an open<br />

source library. Its Aladdin license allows free personal and noncommercial usage, but<br />

for any commercial use you must purchase a license. See http://www.pdflib.com for<br />

details. Open source alternatives include clibpdf (http://www.fastio.com) and the<br />

interesting FreeLibPDF (http://www.fpdf.org), which is written in <strong>PHP</strong>.<br />

Since pdflib is the most mature and has the most features, that is the library we cover<br />

in this chapter. The basic concepts of the structure and features of a PDF file are<br />

common to all the libraries, though.<br />

Documents and Pages<br />

A <strong>PHP</strong> document is made up of a number of pages. Each page contains text and/or<br />

images. This section shows you how to make a document, create pages in that document,<br />

put text onto the pages, and send the pages backto the browser when you’re<br />

done.<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.<br />

233

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!