PHP is a dynamic web development language with some surprising capabilities. It can even create PDF documents on the fly, if right third party library is available. Here in this post we are using FPDF library. You can download the same from here . Following is the example how you can write a simple pdf file using this library: "pdf.php" <?php //Connection to the database $link = mysql_connect("localhost","root",""); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("practice"); //end of database connection code require('fpdf.php'); $pdf=new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',10); $pdf->Cell(50,3,"Learn how to write PDF Files in PHP"); ...