Helping ordinary people create extraordinary websites!

Easy PDF Generation in PHP

By Akash Mehta
2008-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:
 5 Votes

You might also want to check these out:


Leave a Comment on "Easy PDF Generation in PHP"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS