Categories: OpenSourcephp

5 Best opensource PHP pdf generation libraries

PHP is an interpreted server-side scripting language. This means you write PHP code, upload it to a web server, and execute it with an interpreter. PHP is typically used with a web server like Apache or nginx to serve dynamic content. However, PHP can also be used to build powerful command-line applications (just like bash, Ruby, Python, and so on) there are many commnad line PHP pdf library available at the moment . Many PHP developers don’t realize this and miss out on a really exciting feature. Not you, though.

In this article, i have shared 5 best OpenSource PHP pdf generation libraries. these libraries can make your pdf generation more productive.

1. snappy

Snappy is a PHP pdf library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopdf and wkhtmltoimage available on OSX, linux, windows.

Github stats

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage
Forks: 396
Stars: 3647
Open issues: 2
Latest tag: v1.2.1
git clone

If you want to generate table of contents and you want to use custom XSL stylesheet, do the following:

View on Github

2. Wkhtml to pdf

wkhtmltopdf and wkhtmltoimage are 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.

Github stats

Convert HTML to PDF using Webkit (QtWebKit)
Forks: 1373
Stars: 10022
Open issues: 999
Latest tag: 0.12.6
git clone

View on Github

3. Mpdf

mPDF is a PHP pdf library which generates PDF files from UTF-8 encoded HTML. with a number of enhancements. mPDF is released under the GNU GPL v2 licence.

Github stats

PHP library generating PDF files from UTF-8 encoded HTML
Forks: 709
Stars: 2799
Open issues: 293
Latest tag: v8.0.7
git clone

The simplest usage (since version 7.0) of the library would be as follows:

View on Github


This is a yet another html to pdf converter for php. This package uses wkhtmltopdf as a third-party tool so proc_*() functions have to be enabled in your php configurations and wkhtmltopdf tool should be installed in your machine.

Github stats

Yet another HTML to PDF Converter based on wkhtmltopdf
Forks: 20
Stars: 50
Open issues: 0
Latest tag: 2.2.0
git clone

View on Github


Html2Pdf is a HTML to PDF converter written in PHP, and compatible with PHP 5.4 to 7.2. It allows the conversion of valid HTML in PDF format, to generate documents like invoices, documentation.

Github stats

OFFICIAL PROJECT | HTML to PDF converter written in PHP
Forks: 538
Stars: 1123
Open issues: 113
Latest tag: v5.2.2
git clone

View on Github
Deven Rathore

Deven is an Entrepreneur, and Full-stack developer, Constantly learning and experiencing new things. He currently runs and

Published by
Deven Rathore

Recent Posts

Free Applications and Websites to Enhance Coding Skills

Obtaining any skill means that one will continuously upgrade it to become professional. It’s impossible…

3 weeks ago

How to Use Disk Drill Partition Recovery Software for Mac

With the keyboard shortcut "Command(⌘) + Option(⌥) + Delete(⌫)" you can completely remove a file…

3 weeks ago

21 React Project Ideas for Beginners

For some weeks now, you have been putting in a lot of effort in understanding…

1 month ago

Reasons for Creating a Custom Transportation Management Software

Transportation management software is used by organizations to administer, control, and manage the transportation aspect…

1 month ago

21 Angular project ideas for beginners

Angular project ideas have become so handy in bringing evolution and slight changes to many…

2 months ago

Tips for Optimal SaaS Platform Development

According to BetterCloud, approximately 80 percent of mobile applications will be running on mobile software…

2 months ago