A PDF document is made up of a number of pages. Each page contains text and/or images. This section shows you how to make a document, create pages in that document, put text onto the pages, and send the pages back to the browser when you’re done.
The examples in this chapter assume that you have at least the Adobe PDF document viewer installed as an add-on to your web browser. These examples will not work otherwise. You can get the add-on from the Adobe website.
Let’s start with a simple PDF document. Example 10-1 simply places “Hello Out There!” on a page and then displays the resulting PDF document.
Example 10-1. “Hello Out There!” in PDF
// path to fpdf.php
"Hello Out There!"
Example 10-1 follows the basic steps involved in creating a PDF document: creating a new PDF object instance, creating a page, setting a valid font for the PDF text, and writing the text to a “cell” on the page. Figure 10-1 shows the output of Example 10-1.
Figure 10-1. “Hello Out There!” PDF example
In Example 10-1,
we started by making reference to the FPDF library with the
require function. Then the code created a new instance of the FPDF object. You will note that all the calls to the new FPDF instance are ...