mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF
and HTML2FPDF (see CREDITS), with a number of enhancements.
mPDF was written by Ian Back and is released under the GNU GPL v2 licence., (*1)
, (*2)
Installation
Preferred installation method is via composer and its packagist package mpdf/mpdf., (*3)
Manual installation
- Download the .zip release file and unzip it
- Create a folder e.g. /mpdf on your server
- Upload all of the files to the server, maintaining the folders as they are
-
Ensure that you have write permissions set (CHMOD 6xx or 7xx) for the following folders:, (*4)
/ttfontdata/ - used to cache font data; improves performance a lot, (*5)
/tmp/ - used for some images and ProgressBar, (*6)
/graph_cache/ - if you are using JpGraph in conjunction with mPDF, (*7)
To test the installation, point your browser to the basic example file:, (*8)
[path_to_mpdf_folder]/mpdf/examples/example01_basic.php
If you wish to define a different folder for temporary files rather than /tmp/ see the note on
Folder for temporary files
in the section on Installation & Setup in the manual., (*9)
If you have problems, please read the section on troubleshooting in the manual., (*10)
Online manual
Online manual is available at https://mpdf.github.io/., (*11)
Unit Testing
Unit testing for mPDF is done using PHPUnit., (*12)
To get started, run composer install from the command line while in the mPDF root directory
(you'll need composer installed first)., (*13)
To execute tests, run vendor/bin/phpunit from the command line while in the mPDF root directory., (*14)
Any assistance writing unit tests for mPDF is greatly appreciated. If you'd like to help, please
note that any PHP file located in the /tests/ directory will be autoloaded when unit testing., (*15)