Generate PDFs with PHP

There is a lot of PHP code available to generate PDF but most of it requires downloading and installing php extensions. In a shared hosting environment you don't always have access to php configuration, which is why ezPDF is nice. ezPDF is open source PDF generation PHP. See below for an example of 'on the fly' pdf generation, using ezPDF.
     include_once ('class.ezpdf.php');
     //ezpdf: from
     //note: xy origin is at the bottom left
     $colw = array(      80 ,    40,   220,    80,     40  );//column widths
     $rows = array(
         array("WD", "80GB","WD800AAJS SATA2 7200rpm 8mb"        ,"$36.90","Y"),
         array("WD","160GB","WD1600AAJS SATA300 8mb 7200rpm"     ,"$39.87","Y"),
         array("WD", "80GB","800jd SATA2 7200rpm 8mb"            ,"$41.90","Y"),
         array("WD","250GB","WD2500AAKS SATA300 16mb 7200rpm"    ,"$49.88","Y"),
         array("WD","320GB","WD3200AAKS SATA300 16mb 7200rpm"    ,"$49.90","Y"),
         array("WD","160GB","1600YS SATA raid 16mb 7200rpm"      ,"$59.90","Y"),
         array("WD","500GB","500gb WD5000AAKS SATA2 16mb 7200rpm","$64.90","Y"),
         array("WD","250GB","2500ys SATA raid 7200rpm 16mb"      ,"$69.90","Y"),
     //x is 0-600, y is 0-780 (origin is at bottom left corner)
     $pdf =& new Cezpdf('LETTER');
     $image = imagecreatefrompng("background.png");
     $pdf->addText(80,620,10,"List of Hard Drives");
     $pdf->addText(30,16,8,"<b>Created ".date("m/d/Y"));
     foreach($rows as $r)
         $xoffset = $curr_x;
         foreach($r as $i=>$data)
             $pdf->addText( $xoffset, $curr_y , 10, $data );

Download Demo PDF (dynamically generated with php)
Download all-in-one example .zip 349KB (includes ezPDF)

* The above code generates a 1 page pdf, but a multi-page PDF is possible using the $pdf->ezNewPage() function. Any $pdf->addText() or $pdf->addImage() calls after that point are added to the new page.

* The size of a LETTER page in ezPDF is 612x792 (w by h in pixels)
* The (x,y) origin (0,0) is at the bottom left of a PDF page

Further Reading
* ezPDF and
* ezPDF API Docs[pdf]
* pdf-php at sourceforge

Dilantha on 2009-09-15 08:15:46
Great script..I just need to know one more thing. Is it possible to disable copying the content in the generated pdf file?..

Shafiq on 2013-01-30 09:01:51
Thanks Really great script