Top 5 Free Dynamic PDF Generation Libraries in PHP


Top 5 Free Dynamic PDF Generation Libraries in PHP:-
Creating a dynamic PDF is the need of any project to fulfill your clients need, It helps in reporting section of your project. User can see all reports and also can download reports in PDF format or generate invoice in PDF and sent to Client directly, For these need dynamic PDF generation is the need of all the business projects, Every clients demand for PDF reports and auto generated invoice or other required documents in their projects, For full-filling your client need Here I am going to share some popular opensource PDF Generation Libraries in PHP. Which help you to create dynamic PDFs for your projects.


FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.The class can produce documents in many languages other than the Western European ones: Central European, Cyrillic, Greek, Baltic and Thai, provided you own TrueType or Type1 fonts with the desired character set. UTF-8 support is also available.

  • Choice of measure unit, page format and margins
  • Page header and footer management
  • Automatic page break
  • Automatic line break and text justification
  • Image support (JPEG, PNG and GIF)
  • Colors
  • Links
  • TrueType, Type1 and encoding support
  • Page compression

2. Dompdf

Dompdf is an HTML to PDF converter
At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.

  • Handles most CSS 2.1 and a few CSS3 properties, including @import, @media &
    @page rules
  • Supports most presentational HTML 4.0 attributes
  • Supports external stylesheets, either local or through http/ftp (via
  • Supports complex tables, including row & column spans, separate & collapsed
    border models, individual cell styling
  • Image support (gif, png (8, 24 and 32 bit with alpha channel), bmp & jpeg)
  • No dependencies on external PDF libraries, thanks to the R&OS PDF class
  • Inline PHP support
  • Basic SVG support


TCPDF is a PHP library for generating PDF documents on-the-fly easily and with a couple of lines. It support customization and a lot of key features when you work with the creation of PDF files.Like many other PDF scripts is the TCPDF project based on FPDF, too. The TCPDF class was in the beginning a rewrite for PHP5 with the support for UTF-8. Now is this project a great PDF generator with great image functions including support for the CMYK color mode.

  • no external libraries are required for the basic
  • all standard page formats, custom page formats, custom margins
    and units of measure;
  • UTF-8 Unicode and Right-To-Left languages;
  • TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and
    CID-0 fonts;
  • font subsetting;
  • methods to publish some XHTML + CSS code, Javascript and
  • images, graphic (geometric figures) and transformation
  • supports JPEG, PNG and SVG images natively, all images
    supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM)
    and all images supported via ImagMagick (http:
  • 1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9,
    CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128
    A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A,
    UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer
    Code), CBC (Customer Bar Code), KIX (Klant index – Customer index),
    Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11,
  • ICC Color Profiles, Grayscale, RGB, CMYK, Spot Colors and
  • automatic page header and footer management;
  • document encryption up to 256 bit and digital signature
  • transactions to UNDO commands;
  • PDF annotations, including links, text and file
  • text rendering modes (fill, stroke and clipping);
  • multiple columns mode;
  • no-write page regions;
  • bookmarks and table of content;
  • text hyphenation;
  • text stretching and spacing (tracking/kerning);
  • automatic page break, line break and text alignments including
  • automatic page numbering and page groups;
  • move and delete pages;
  • page compression (requires php-zlib extension);
  • XOBject templates;
  • PDF/A-1b (ISO 19005-1:2005) support.

4. wkhtmltopdf

wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely “headless” and do not require a display or display service.

5. mPDF

mPDF is another useful library to create dynamic PDFs.mPDF website is now closed down but You can still download the latest mPDF package, and some example files from the site. mPDF is based on FPDF and HTML2FPDF, with a number of enhancements. The script is able to process utf-8 encoded HTML code and is able to use CSS stylesheets for the generated PDF layout.