How to generate PDF files with PHP?


1 reply [Last post]
raja
Offline
Joined: 11/19/2010

[URL="http://www.fpdf.org/"]FPDF[/URL] is a PHP class that allows you to generate PDF files without using the PDFlib library.

FPDF is free and can be downloaded from the official website's [URL="http://www.fpdf.org/en/download.php"]download section[/URL]. The download package contains all necessary files, along with some [URL="http://www.fpdf.org/en/tutorial/index.php"]tutorials[/URL] on how to use it.

A basic example of using FPDF is with the following PHP code (you must download and extract the FPDF package in the folder where the PHP file with the code is located):

[I] <?php
require('[B]fpdf.php[/B]');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('[B]Arial[/B]','[B]B[/B]',[B]16[/B]);
$pdf->Cell(40,10,'[B]Hello World![/B]');
$pdf->Output();
?>[/I]

You can see the PDF file created with the above code at [URL="http://www.fpdf.org/en/tutorial/tuto1.php"]this URL[/URL].