Open Source PHP Library for Processing PDF Files
Create, Modify, and Manipulate PDF Documents, Add Tables, Headers & Footers to PDF Files via PHP API.
mPDF is an Open source PHP Library that enables users to create, modify, and manipulate PDF documents inside their own PHP application. The library supports PDF creation from UTF-8 encoded HTML and accepts UTF-8 encoded HTML. It auto-detect RTL characters within a document and Transfers tables, lists, table cell alignment, justified text as well as full-text reversal for RTL characters. Moreover, it also auto-detects non-RTL characters and displays it in the original order.
The library has included support for several important basic and advanced features for PDF documents management, such as PDF creation, Bookmarks, CSS style sheets, PDF Page layout, and orientation, inserting tables or nested tables, adding images ( JPG, GIF, PNG, SVG, BMP or WMF format, Text justification, PDF documents security, headers & footers, page numbering, and many more.
At A Glance
An overview of mPDF features.
- UTF-8 encoding
- RTL languages
- CJK languages
- CSS stylesheets
- Page layout
- Page orientation
- Headers & footers
- Nested tables
- Extract text
mPDF only requires PHP runtime.
- PHP 5.3 and above.
Getting Started with mPDF
The Official installation method for mPDF library is through composer packagist package mpdf/mpdf. Please use the following command for a smooth installation.
Install mPDF via composer
$ composer require mpdf/mpdf
PDF Files Creation from UTF-8 Encoded HTML
mPDF library provides functionality for creating PDF documents from UTF-8 encoded HTML inside PHP application. UTF-8 encoded HTML is accepted as the standard input. Once the PDF file is created, you can also make changes to it according to your own needs. The library facilitates you to insert new pages, add new content, insert images, use bookmarks, add headers & footers to an existing page, and much more.
Add Tables to PDF via PHP
The open source library mPDF gives software developers the ability to add and modify tables inside a PDF document. The library supports CSS styles for tables/cells and custom attributes adding a horizontal border at the top and bottom of the table. It also includes support for border-collapse (CSS border-collapse:collapse or separate), as well as cellSpacing and cellPadding. Moreover, you can rotate tables, AutosizePermalink, repeating Table Header row on a new page, and many more.
Add Headers & Footers to PDF File
The mPDF library includes support for adding headers & footers to a PDF document via PHP. The library provides a number of different ways to set page headers and page footers in a PDF, such as defines a header/footer for the whole document, includes images in a header/footer, complex headers/footers with the advantage of HTML code, setting the header/footer at the start of a document and much more.
Create Password Protected PDF Documents
The mPDF library includes complete support for settings security of the PDF documents. The library gives users the ability to determine whether the document is encrypted and what permissions are granted to the user. It also enables you to set a password for opening the PDF document or to modify the PDF document.