Knowledge Base Article

How to generate PDF files with PHP?

FPDF 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 download section. The download package contains all necessary files, along with some tutorials 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):

 

 <?php
require('fpdf.php');

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

 

You can see the PDF file created with the above code at this URL.



Rating

Please indicate if this article was helpful for you.

rating :  4.7 from 5
views :  1130
votes :  9

Related Articles

Views

Haven't found what you are looking for? Suggest an article HERE.

powered by

Valid XHTML 1.0 Strict Valid CSS!