| Viewed 84 times

How to create a pdf file in PHP

How to create a pdf file in PHP

1 Answer
Mohammad Qandeel

I suggest you to use a free PHP Class  FPDF  to generate PDF files with pure PHP version  PHP 5.1 at least

you can edit Page header and footer too and it's supporting (JPEG, PNG, and GIF) Image and UTF-8 Unicode.

You can download FPDF through their official website and choose the right version for you

Then you must upload the files to your site

for example


    $pdf = new FPDF(); // you can change the constructor value  FPDF('P','mm','A4');
    $pdf->SetFont('Arial','B',16); // font size is given in points, not millimeters 
    $pdf->Cell(40,10,'Hello World!');

When you try to run the previous code the document is closed and sent to the browser with Output() function

You can also see the many examples available on the official website Tutorials