Skip to Content

Generate PDF with PHP - Create Dynamic PDF Files in PHP

Do you want to create PDF Files dynamically in PHP online for your commercial software? Now you can do it with FPDF class library. FPDF is a PHP class which allows to generate PDF files with pure PHP without depending on external library such as PDFlib.

What?s wrong with PDFlib? well for starters, PDFlib support need to be compiled in the php to make it work, secondly PDFlib isn?t free software meaning that you need to buy a separate license if you with to use PDFlib to generate pdf docs for your commercial apps and business. On the other hand, though not stated in a formal form, FPDF is freely distributable with or without modification and there are no restriction on the use of FPDF class library.

Generate PDF files in PHP

There is another library which is commonly use with PHP, cpdf. Though seems interesting, cpdf only allows the use of it?s library for non-commercial purpose without license, thus it is not a ?Free Software? and conflicted with OSI definition of ?Open Source?.

Being a pure PHP implementation, FPDF suffers from the lack speed of PDFlib, but the performance degradation won?t be noticeable unless you are planning to generate a large pdf files. FPDF library has been ported to other languages like Ruby, PHP and and C++ as there?s no restriction imposed on it.

Here?s a link to those who are interested to use FPDF in their projects http://www.fpdf.org

HTML to PDF Conversion in PHP

The html2pdf PHP class, which allows one-click conversion of HTML or XHTML to PDF. It is an extension of FPDF class mentioned above which is the most serious opensource implementation of the pdf format in PHP. We’ve found some scripts those seem to do quite a good job and they are mentioned below. They are all html2pdf conversion scripts.

  1. html2ps and html2pdf
  2. html2pdf - convert your XHTML to PDF easily
  3. HTML to PDF conversion script
  1. Thanks a lot for the information. I was looking for a way to generate PDF files on the fly with PHP and this class serves the purpose very well.

Powered by PHPKB Knowledge Base Software