1 mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML.
3 It is based on [FPDF](http://www.fpdf.org/) and [HTML2FPDF](http://html2fpdf.sourceforge.net/)
4 (see [CREDITS](CREDITS.txt)), with a number of enhancements. mPDF was written by Ian Back and is released
5 under the [GNU GPL v2 licence](LICENSE.txt).
7 [![Latest Stable Version](https://poser.pugx.org/mpdf/mpdf/v/stable)](https://packagist.org/packages/mpdf/mpdf)
8 [![Total Downloads](https://poser.pugx.org/mpdf/mpdf/downloads)](https://packagist.org/packages/mpdf/mpdf)
9 [![License](https://poser.pugx.org/mpdf/mpdf/license)](https://packagist.org/packages/mpdf/mpdf)
12 > Note: If you are viewing this file on mPDF GitHub repository homepage or on Packagist, please note that
13 > the default repository branch is `development` which can differ from the last stable release.
18 PHP versions and extensions
19 ---------------------------
21 - `mPDF >=7.0` is supported on PHP `^5.6 || ~7.0.0 || ~7.1.0 || ~7.2.0`
22 - `PHP 7.3` is supported since `mPDF v7.1.7`
23 - `PHP 7.4` is supported since `mPDF v8.0.4`
26 PHP `mbstring` and `gd` extensions have to be loaded.
28 Additional extensions may be required for some advanced features such as `zlib` for compression of output and
29 embedded resources such as fonts, `bcmath` for generating barcodes or `xml` for character set conversion
35 mPDF has some problems with fetching external HTTP resources with single threaded servers such as `php -S`. A proper
36 server such as nginx (php-fpm) or Apache is recommended.
41 Consider supporting development of mPDF with a donation of any value. [Donation button][1] can be found on the
42 [main page of the documentation][1].
47 Official installation method is via composer and its packagist package [mpdf/mpdf](https://packagist.org/packages/mpdf/mpdf).
50 $ composer require mpdf/mpdf
56 The simplest usage (since version 7.0) of the library would be as follows:
61 require_once __DIR__ . '/vendor/autoload.php';
63 $mpdf = new \Mpdf\Mpdf();
64 $mpdf->WriteHTML('<h1>Hello world!</h1>');
69 This will output the PDF inline to the browser as `application/pdf` Content-type.
74 All [configuration directives](https://mpdf.github.io/reference/mpdf-variables/overview.html) can
75 be set by the `$config` parameter of the constructor.
77 It is recommended to set one's own temporary directory via `tempDir` configuration variable.
78 The directory must have write permissions (mode `775` is recommended) for users using mPDF
79 (typically `cli`, `webserver`, `fpm`).
81 **Warning:** mPDF will clean up old temporary files in the temporary directory. Choose a path dedicated to mPDF only.
87 $mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/tmp']);
91 By default, the temporary directory will be inside vendor directory and will have correct permissions from
92 `post_install` composer script.
94 For more information about custom temporary directory see the note on
95 [Folder for temporary files](https://mpdf.github.io/installation-setup/folders-for-temporary-files.html)
96 in the section on Installation & Setup in the [manual][1].
98 If you have problems, please read the section on
99 [troubleshooting](https://mpdf.github.io/troubleshooting/known-issues.html) in the manual.
104 Online manual is available at https://mpdf.github.io/.
106 For general questions or troubleshooting please use the [mpdf tag](https://stackoverflow.com/questions/tagged/mpdf) at Stack Overflow (and not the project's issue tracker).
111 Please read before submitting issues and pull requests the [CONTRIBUTING.md](https://github.com/mpdf/mpdf/blob/development/.github/CONTRIBUTING.md) file.
116 Unit testing for mPDF is done using [PHPUnit](https://phpunit.de/).
118 To get started, run `composer install` from the command line while in the mPDF root directory
119 (you'll need [composer installed first](https://getcomposer.org/download/)).
121 To execute tests, run `vendor/bin/phpunit` from the command line while in the mPDF root directory.
123 Any assistance writing unit tests for mPDF is greatly appreciated. If you'd like to help, please
124 note that any PHP file located in the `/tests/` directory will be autoloaded when unit testing.
126 [1]: https://mpdf.github.io