Easy PDF Generation in PHP
By Akash Mehta2008-03-01
Hello World with FPDF
Let's get started with some basic PDF generation using FPDF. Load up your code editor and bash out the following:
<?php
require('fpdf.php');
$PDF = new FPDF();
$PDF->AddPage();
$PDF->SetFont('Arial', 'B', 16);
$PDF->Cell(40, 10, 'Hello World!');
$PDF->Output();
I'll explain what all this does in a moment. For now, grab the latest version of FPDF from fpdf.org, extract it to somewhere in your web server's document root and save this snippet in a PHP file under the same folder as fpdf.php. Load it up in your web browser and you should see something like this:

Nothing special, but we're on our way to PDF glory!
Tutorial Pages:
» Introduction
» Why would you want to generate PDFs?
» Options for PDF Generation
» Hello World with FPDF
» Examining the code
» Further reading on FPDF
