Top 5 : Best open source PDF generation libraries for PHP (2022)

See our collection from 5 of the best PDF generator libraries for PHP.

The automatic creation of PDF files is one of the most important points of a project (commercial or not). As probably, the generated PDF's are not for you or team but for your demanding clients, you need to provide asolution that meets all expectations and requirements.

In some cases, not because of exaggerated customer requirements but the library you use to generate PDF's, you'll find yourself limited and most likely in problems to provide a solution for the client.

In this article, we are going to show 5 of the most imponent PDF generation libraries that will help you to achieve those complex and extense PDF's.

This top is based in different points as how easy are theyto implement, use cases, library users, functionsanddevelopment status.



(Video) How To Create a PDF using PHP - Simple Tutorial (2019)

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.

FPDF has other advantages: high level functions, between its main features are:

  • 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.

FPDF requires no extension (except Zlib to enable compression and GD for GIF support). The latest version requires at least PHP 5.1.

The following snippet show a basic PDF generated with FPDF :

<?phprequire('fpdf/fpdf.php');$pdf = new FPDF();$pdf->AddPage();$pdf->SetFont('Arial','B',16);$pdf->Cell(40,10,'Hello World!');$pdf->Output();?>

4. mPDF

mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF , with a number of enhancements. mPDF was written by Ian Back and is released under the GNU GPL v2 licence.

(Video) Dynamic generate pdf portfolio report using tcpdf & php mysql

Before start using it, we encorage you to read the documentation located at

The following snippet show a basic PDF after a composer installation with mPDF :

<?phprequire_once __DIR__ . '/vendor/autoload.php';$mpdf = new mPDF();// Write some HTML code:$mpdf->WriteHTML('<h1>Hello World</h1><br><p>My first PDF with mPDF</p>');// Output a PDF file directly to the browser$mpdf->Output();?>



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 fopen-wrappers)
  • 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


  • PHP version 5.3.0 or higher
  • DOM extension
  • GD extension
  • MBString extension
  • php-font-lib
  • php-svg-lib


  • OPcache (OPcache, XCache, APC, etc.): improves performance
  • IMagick or GMagick extension: improves image processing performance

The following snippet shows how to generate a simple PDF and generate a direct download using Dompdf :

(Video) Create PDF files from HTML using PHP and mPDF | Quick programming tutorial

<?phprequire_once 'dompdf/';// reference the Dompdf namespaceuse Dompdf\Dompdf;// instantiate and use the dompdf class$dompdf = new Dompdf();$dompdf->loadHtml('<h1>DOMPDF Demo</h1><br><p>Hello World !</p>');// (Optional) Setup the paper size and orientation$dompdf->setPaper('A4', 'portrait');// Render the HTML as PDF$dompdf->render();// Output the generated PDF to Browser$dompdf->stream();

2. Snappy (wkhtmltopdf)

Github Snappy Library| Github wkhtmltopdf

Snappy is a PHP5 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. You will have to download wkhtmltopdf 0.12.x in order to use Snappy.

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.

You can even download a wkhtmltopdf distribution as a composer dependency and reference the Binary dinamically in your project.

The following snippet show a basic PDF from HTML using wkhtmltopdf in Windows with the Github homepage:

(Video) How to Generate PDF File in PHP using Dompdf, fpdf, jspdf libraries

<?phprequire __DIR__ . '/vendor/autoload.php';use Knp\Snappy\Pdf;// For example, in windows use the wkhtmltopdf executable file$snappy = new Pdf('wkhtmltopdf.exe');// Download the streamed PDFheader('Content-Type: application/pdf');header('Content-Disposition: attachment; filename="file.pdf"');echo $snappy->getOutput('');


Github | Homepage

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.

This library supports Unicode fonts and it is actively maintained by Nicola Asuni in the Github repository.

It has a extense collection of examples and ready-to-test snippets on its official homepage.TCPDF has as main features :

  • No external libraries are required for the basic functions.
  • all standard page formats, custom page formats, custom margins and units of measure.
  • UTF-8 Unicode and Right-To-Left languages.
  • TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1 and CID-0 fonts.
  • font subsetting.
  • methods to publish some XHTML + CSS code, Javascript and Forms.
  • images, graphic (geometric figures) and transformation methods.
  • 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 (
  • 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 Extension, 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, PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix, QR-Code, PDF417.
  • JPEG and PNG ICC profiles, Grayscale, RGB, CMYK, Spot Colors and Transparencies.
  • automatic page header and footer management.
  • document encryption up to 256 bit and digital signature certifications.
  • transactions to UNDO commands.
  • PDF annotations, including links, text and file attachments.
  • text rendering modes (fill, stroke and clipping).
  • multiple columns mode.
  • no-write page regions.
  • bookmarks, named destinations and table of content.
  • text hyphenation.
  • text stretching and spacing (tracking).
  • automatic page break, line break and text alignments including justification.
  • automatic page numbering and page groups.
  • move and delete pages.
  • Page compression (requires php-zlib extension).
  • XOBject Templates.
  • Layers and object visibility.
  • PDF/A-1b support.

The following example how to render HTML as PDF with TCPDF :

(Video) Generate PDF Invoice Using PHP, MySQL and Dompdf Library

<?php // Include the main TCPDF library (search for installation path).require_once('tcpdf_include.php');// create new PDF document$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);// set document information$pdf->SetCreator(PDF_CREATOR);$pdf->SetAuthor('Our Code World');$pdf->SetTitle('Example Write Html');// set default header data$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);// set header and footer fonts$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));// set default monospaced font$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);// set margins$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);// set auto page breaks$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);// set image scale factor$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);// add a page$pdf->AddPage();$html = '<h4>PDF Example</h4><br><p>Welcome to the Jungle</p>'; $pdf->writeHTML($html, true, false, true, false, '');// add a page$pdf->AddPage();$html = '<h1>Hey</h1>';// output the HTML content$pdf->writeHTML($html, true, false, true, false, '');// reset pointer to the last page$pdf->lastPage();//Close and output PDF document$pdf->Output('example_006.pdf', 'I');

TCPDF in the first place, why?. Theoretically, the first place should be of wkhtmltopdf as it uses webkit to render your HTML and probably will be more helpful to render things as canvas, SVG etc. However, you need to know that not every developer is able to include binaries (application or executables) on its projects or enjoy the privileges of do whatever he wants with the server, that's when TCPDF becomes the first option for the most developers.

TCPDF is on the first place of this top as it is the most easy to use PHP library to create PDF's and however, the most complete and extense as it doesn't require executable files as everything works with Plain PHP. Itcovers the basic requirements of all project that requires the PDF generation feature.

If you know another awesome PHP library to generate PDF, please share it with the community in the comment box down below, have fun !


Which is best mPDF or FPDF? ›

mpdf is superior to FPDF for language handling and UTF-8 support. For CJK support it not only supports font embedding, but font subsetting (so your CJK PDFs are not oversized). TCPDF and FPDF have nothing on the UTF-8 and Font support of mpdf. It even comes with some open source fonts as of version 5.0.

What is the best program to create PDF? ›

The best product for creating PDF files is Adobe Acrobat, which includes Acrobat Distiller for writing PDF files. You can purchase Acrobat at most software retailers or at Adobe's web site. Ghostscript - compiles TeX and LaTeX files directly into PDF.

Which is the best PDF maker in the world? ›

1. Foxit PDF Creator. Foxit PDF creator is an Android PDF Creator app and most people get to know this Android app from their desktop PDF reader. It is one of the best PDF software brand and its desktop software has got wide popularity.

We review five top APIs for generating PDFs, either from static HTML or from template-driven applications. Anvil, Paperplane, PDF Generator, and others

Below we’ll be looking at a few services capable of accepting API calls to generate PDFs.. Such tools could empower non-technical team members to make tweaks to templates without the need to enlist developers or designers’ help.. Anvil’s website puts its purpose pretty simply: “post JSON, receive PDF.” Its REST endpoint enables you to fill a templatized PDF using the data you provide.. This is a product to “convert your PDF forms into simple, intuitive websites that fill the PDFs and gather signatures for you.” Offering integrations with services like DocuSign and CRM software, it feels very much like Anvil is using their PDF filling API as a stepping stone to a more comprehensive workflow automation service.. Paperplane has a tiered pricing plan, with most features included in all plans:

Best free & open-source PDF software enables users to view & share the document easily. It allows businesses to scan & manipulate the document with security.

With the help of PDF editor software , the users can seamlessly edit a PDF and can transform a PDF file into something that can be edited.. The standard file types like.doc and .xls file types can be converted into PDF files with the help of PDF editors.. Multiple file formats – The PDF software can convert the different file types to PDF that helps in displaying the content correctly.. You can also customize the operations of PDF software by opting for an open source PDF file editor software.. Merges PDF files Extract pages from PDF files Rotate PDF files Split a PDF file at given page numbers Annotations Convert to PDF Content Editing Digital signature Encryption PDF Reader Watermarking Merge/Append Insert pages or hyperlinks Create fillable forms Optical Character Recognition module (OCR) Protects PDF files Combine and reorder Crop, split and delete. The users can create PDF files from any application with this open source online PDF file software.. Annotations Content Editing Convert to PDF Digital Signature Encryption Merge/Append PDF Reader Create PDF Files Secure PDFs Digital signatures Archive-ready with PDF/A (Portable Document Format/ Archiving) Easy Access Automatic Saving Merge and rearrange Tokens and actions COM interface Multilingual. The user can use this online PDF file editor software as a PDF reader and open source PDF editor.. Conversion of files Password protection Personalization tools Multi-platform support Advanced options Annotations Content Editing Convert to PDF Encryption Merge/Append PDF Reader PDF manipulating Library based. PDFlite is the free and open source PDF software that enables the user to convert any document or image to a PDF file.

To keep track of books issued, returned & fine charged, you need help of technology. Check list of top 10 free library management software that can be used.

Free library management software further makes the task of managing books in libraries easier.. Most. educational institutions use free and open source library management software,. which helps automate acquisition and inventory management functions.. Catalogue management Subscription management Online access of books with their location & availability Online search option for the inventory Inventory management Periodicals management Patron management Online access to the catalogue of various public libraries Self check-in & check-out Acquisition management Barcode scanning. The efficiency of people managing the library increased by using an open source library management software.. Let’s. have a look at the few of the best free library management software you can use. to manage your library online:. Koha. library software is free library management software which is web based.. Evergreen. library software is a scalable software for all libraries which helps library. managers manage inventory effortlessly.. With this free open source digital library software, get features like acquisition management and circular management.. This open source library management system is a form of integrated library management system which supports circulation, cataloging, and acquisitions.. It is the only open source library management system that is not using a third party content management system for managing the portal.. This. is an open source library management software used for administration purposes. and managing books in your library.. Librarian open. source library management system is used where an efficient and easy library. system is demanded all the time.. This open source library management software gives serial control to manage circulation.. This free library management system supports an ARM architecture You can drag and drop cover images according to your need Get customized display facility with this open source management software You can also customize data related to individual items.

A free and open source Digital Signature Software signs documents using public key infrastructure, which is verifiable by a Certificate Authority.

Cost of buying paper and registers, Costs involved in creating, duplication and circulating of the paper documents, Time and employee cost spent in filing the documents and retrieving paper documents from a cluster of files, Printing costs including the repair and maintenance costs for fax machines, printers, and xerox machines, Storage costs for buying cabinets and shelves, Space costs as the paper documents occupy a significant portion of the office space, time and labor cost spent in search of the lost documents, Damages involved when the paper document that went missing and was never found, and Costs due to negligence in handling paper thereby causing its fraudulent misuse.. Digital Signature Software tracks all the documents that require signatures, and it sends regular reminders to the signers about the documents that need signatures.. Loading certificates from a local user store Time-stamped signature PDF encryption in password format Document metadata can be changed Certificate verification Custom signature image PDF page preview Add custom text inside the visible signature Detailed reports of all signed documents High-level security through encryption. Upload and draw signatures Sign PDF files Convert DOCX to PDF and add words to PDF files Request other non-users to sign documents via e-mail Valid self-signed digital signature Email and in-App notifications No need to create accounts each time-Guest login is allowed Add initials, date, company name, address and full name automatically Upload and manage templates Create files and folders (File system) Real-time signing request notifications It has a beautiful and responsive User Interface Import and add customers Request signatures for specific marked points Import files from Dropbox and Google docs Fast processing speed Send an automated reminder for late signing. Directly imports document to DocHub from the mailbox Drag and drop signature DocHub guides the recipients through the requested document until its signed Can send the same document to multiple users with a sign request It records the authentication details and a legal audit trail Intuitive interface The Field Manager lets users modify existing fields Users can create new fields for signatures, initials, and more.. Can sign 2,000 Documents per account 5 eSignatures can be signed per document per month 3 Sign Requests can be sent per month 3 Emails can be sent per day 3 Email Recipients can be sent documents per day 7 Saved Signatures and initials allowed per account. Various pre-defined templates available for signing Add logo and company seal to your digital signature page An audit trail that tracks all logs such as email address, IP address, all activities that occurred in a day SSL encryption that makes sure bank-level security Integration with various external application-Box, Evernote, etc It supports around 17 types of file formats E-signly performs the legitimacy check to verify the signer identity It records all step by step process involved in signing a document for evidence The verification is done through various methods - SMS passcode customary login/secret key, security answer, and more It works with any web-enabled device, laptop, smartphone, or tablet.. Audit Trail keeps records of all logs related to the digital signature process Receive and send signed contracts In the advanced version, one gets data validation to authenticate signatures Share signed documents Advanced admin features and user reporting In-person signing Branding by using your company’s logo on the document.

Open source form builder apps come in all shapes and sizes but are critically different. This guide covers what's unique about the best open source form builder apps in 2021.

A form builder is a software-based tool that helps users build online forms with little to no code.. The design of the builder is superior to other builders on this list.. Kinto Form builder is an open-source form builder built with React on top of Kinto.. The design is not very opinionated but functional.. Cons Design of the platform Design of the form components Enterprise feel

Instead of using an open source PDF editor to edit PDF on Windows, PDFelement Pro provides you multiple PDF editing tools to edit and convert PDF files on Windows easily.

Is there an open source PDF editor?What is the best open source PDF editor?. This open-source PDF editor was created to be like Microsoft Word so that it can open and edit PDF files easily.. However, it will still do the basics, and it is an open source PDF editor for Windows, so it is always available to edit your PDF files.. PDF Architect Free is an open source PDF editor created by PDF Forge.. More than edit PDF files easily, it can convert PDF, merge PDF, OCR scanned PDF, secure PDF, sign PDF, and more.

Apr 14, 2016 Ok. Admin akan Share Membuat Report / Laporan PDF di PHP dengan HTML2PDF, artikel ini admin admin dari mbak anggun, yang admin rasa cukup bermanfaat. Kalo seblumnya admin sudah pernah...

I want that when A new section is about to start and the control is nearly at the end of the page then that section should begin from next page rather some part of it on page 1 and remaining on page 2.. Apr 23, 2020 · Step 2 – As we have a long HTML page to get converted into multiple PDF pages, so will break the whole HTML page into multiple chunks of pages with the help of selectors like we are using page1, page2 and page3 classes.. I want that when A new section is about to start and the control is nearly at the end of the page then that section should begin from next page rather some part of it on page 1 and remaining on page 2.. I want that when A new section is about to start and the control is nearly at the end of the page then that section should begin from next page rather some part of it on page 1 and remaining on page 2.. Ionic bonding puzzle activity worksheet answer key Sep 07, 2017 · jsPDF / html2pdf: add header and footer text to each page In a recent project I needed to add header and footer text (like page count) to every single generated html2pdf / jsPDF page.. It causes the break to appear as the first tag in the second page, and it generated a page break at the beginning of the page.. page 1. some text page 2. blank page 3. some text Is there anyway that i can specify the page break so that it. May 10, 2013 · How to break pages and HTML tables in htmltools application by using CSS Page Breaks When Converting HTML to PDF?. Print to PDF file with password via command line How to make concrete lion statue May 10, 2013 · How to break pages and HTML tables in htmltools application by using CSS Page Breaks When Converting HTML to PDF?. It causes the break to appear as the first tag in the second page, and it generated a page break at the beginning of the page.. page 1. some text page 2. blank page 3. some text Is there anyway that i can specify the page break so that it. The converter offers a lot of powerful options (convert any web page to pdf, convert any html string to pdf, html5/css3/javascript support, headers and footers support, etc) and the only limitation is that it can generate pdf documents ... Feb 27, 2018 · Use the pageBreakInside property in JavaScript to set the page-break behavior inside an element.Use the auto property to insert page break inside an element.Use auto or avoid property value to automatically insert page break inside an element, if needed, or avoid a page break, respectively.. May 10, 2013 · How to break pages and HTML tables in htmltools application by using CSS Page Breaks When Converting HTML to PDF?. May 10, 2013 · How to break pages and HTML tables in htmltools application by using CSS Page Breaks When Converting HTML to PDF?

Export web pages to PDF files using one of the best HTML to PDF converters.

The best HTML to PDF converters streamline the process of saving a webpage as a PDF file, so you can share or archive the document.. (Image credit: Convertio)Best HTML to PDF converter overall. Reasons to buy +Supports more than 300 file formats. There are upload options because Convertio is a tool for converting a large number of different file formats, not just web pages.. In this case, since we’re converting HTML web pages, we’d choose the option to paste in a URL, select PDF as the format to convert to, and click Convert.. While Convertio is a single tool for converting to many different file formats, PDF24 Tools has a separate tool for each type of conversion.. Reasons to avoid -Slower conversion than other tools. Once you find the page for converting HTML to PDF, there are no settings to change or options to choose; just enter your URL and click the Get PDF button.. Unlike some converters, which split the PDF up into separate pages based on standard page sizes, Soda PDF creates a single, long PDF page equal in length to however long the HTML page you’re converting might be.. The free online version is also limited to creating two PDFs per hour.. HTML to PDF converters transform HTML files into versatile PDF files.


1. How to Create PDF File in Php from Database
(OnlineITtuts Tutorials)
2. How To Fill A Fillable PDF Form with PHP using PDFtk
(Mr Digital)
3. How to Generate Dynamic PDF File using TCPDF in PHP
4. 5 amazing websites to download books for FREE!
5. 10 BEST Linux Applications: Must Have Software (2021)
6. Creating Dynamic PDF file in PHP and HTML
(Vicode Media)

You might also like

Latest Posts

Article information

Author: Lidia Grady

Last Updated: 06/09/2022

Views: 6435

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.