2017 © Pedro Peláez
 

library mpdf

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

image

mpdf/mpdf

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  • Monday, July 2, 2018
  • by finwe
  • Repository
  • 121 Watchers
  • 1346 Stars
  • 3,490,230 Installations
  • PHP
  • 194 Dependents
  • 32 Suggesters
  • 433 Forks
  • 223 Open issues
  • 35 Versions
  • 11 % Grown

The README.md

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML., (*1)

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., (*2)

Latest Stable Version Total Downloads License, (*3)

⚠ If you are viewing this file on mPDF GitHub repository homepage or on Packagist, please note that the default repository branch is development which can differ from the last stable release., (*4)

Requirements

PHP versions and extensions

  • PHP >=5.6 <7.3.0 is supported for mPDF >= 7.0
  • PHP 7.3 is supported since mPDF v7.1.7
  • PHP 7.4 is supported since mPDF v8.0.4
  • PHP 8.0 is supported since mPDF v8.0.10
  • PHP 8.1 is supported as of mPDF v8.0.13
  • PHP 8.2 is supported as of mPDF v8.1.3
  • PHP 8.3 is supported as of mPDF v8.2.1
  • PHP 8.4 is supported as of mPDF v8.2.5

PHP mbstring and gd extensions have to be loaded., (*5)

Additional extensions may be required for some advanced features such as zlib for compression of output and embedded resources such as fonts, bcmath for generating barcodes or xml for character set conversion and SVG handling., (*6)

Known server caveats

mPDF has some problems with fetching external HTTP resources with single threaded servers such as php -S. A proper server such as nginx (php-fpm) or Apache is recommended., (*7)

Support us

Consider supporting development of mPDF with a donation of any value. [Donation button][1] can be found on the [main page of the documentation][1]., (*8)

Installation

Official installation method is via composer and its packagist package mpdf/mpdf., (*9)

$ composer require mpdf/mpdf

Usage

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

<?php

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('

Hello world!

'); $mpdf->Output();

This will output the PDF inline to the browser as application/pdf Content-type., (*11)

Setup & Configuration

All configuration directives can be set by the $config parameter of the constructor., (*12)

It is recommended to set one's own temporary directory via tempDir configuration variable. The directory must have write permissions (mode 775 is recommended) for users using mPDF (typically cli, webserver, fpm)., (*13)

Warning: mPDF will clean up old temporary files in the temporary directory. Choose a path dedicated to mPDF only., (*14)

<?php

$mpdf = new \Mpdf\Mpdf(['tempDir' => __DIR__ . '/tmp']);

By default, the temporary directory will be inside vendor directory and will have write permissions from post_install composer script., (*15)

For more information about custom temporary directory see the note on Folder for temporary files in the section on Installation & Setup in the [manual][1]., (*16)

If you have problems, please read the section on troubleshooting in the manual., (*17)

About CSS support and development state

mPDF as a whole is a quite dated software. Nowadays, better alternatives are available, albeit not written in PHP., (*18)

Use mPDF if you cannot use non-PHP approach to generate PDF files or if you want to leverage some of the benefits of mPDF over browser approach – color handling, pre-print, barcodes support, headers and footers, page numbering, TOCs, etc. But beware that a HTML/CSS template tailored for mPDF might be necessary., (*19)

If you are looking for state of the art CSS support, mirroring existing HTML pages to PDF, use headless Chrome., (*20)

mPDF will still be updated to enhance some internal capabilities and to support newer versions of PHP, but better and/or newer CSS support will most likely not be implemented., (*21)

Online manual

Online manual is available at https://mpdf.github.io/., (*22)

General troubleshooting

For general questions or troubleshooting please use Discussions., (*23)

You can also use the mpdf tag at Stack Overflow as the StackOverflow user base is more likely to answer you in a timely manner., (*24)

Contributing

Before submitting issues and pull requests please read the CONTRIBUTING.md file., (*25)

Unit Testing

Unit testing for mPDF is done using PHPUnit., (*26)

To get started, run composer install from the command line while in the mPDF root directory (you'll need composer installed first)., (*27)

To execute tests, run composer test from the command line while in the mPDF root directory., (*28)

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., (*29)

The Versions

02/07 2018

dev-test

dev-test https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0 GPL-2.0-only

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

02/07 2018

dev-master

9999999-dev https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0 GPL-2.0-only

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

02/07 2018

v7.1.1

7.1.1.0 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0-only

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

02/07 2018

dev-development

dev-development https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0 GPL-2.0-only

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

18/05 2018

v7.1.0

7.1.0.0 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0-only

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

03/01 2018

v7.0.3

7.0.3.0 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

28/12 2017

dev-tag-refactoring

dev-tag-refactoring https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

22/11 2017

7.0.2

7.0.2.0 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

20/10 2017

v7.0.1

7.0.1.0 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

19/10 2017

v7.0.0

7.0.0.0 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

16/10 2017

v7.0.0-RC4

7.0.0.0-RC4 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

11/10 2017

v7.0.0-RC3

7.0.0.0-RC3 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

07/10 2017

v7.0.0-RC2

7.0.0.0-RC2 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

26/09 2017

v7.0.0-RC1

7.0.0.0-RC1 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

09/07 2017

6.1.x-dev

6.1.9999999.9999999-dev http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

09/07 2017

v6.1.4

6.1.4.0 http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

12/03 2017

v7.0.0-beta2

7.0.0.0-beta2 https://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

09/03 2017

dev-barcode-hide-numbers

dev-barcode-hide-numbers http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

08/03 2017

v7.0.0-beta1

7.0.0.0-beta1 http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

12/12 2016

v6.1.3

6.1.3.0 http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

25/08 2016

v6.1.2a

6.1.2.0-alpha http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

20/07 2016

v6.1.2

6.1.2.0 http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

28/04 2016

v6.1.1

6.1.1.0 http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

26/04 2016

v6.1.0

6.1.0.0 http://mpdf.github.io

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ian Back

php utf-8 pdf

01/03 2015

v6.0.0

6.0.0.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

17/12 2014

v5.7.4a

5.7.4.0-alpha http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

14/12 2014

v5.7.4

5.7.4.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

22/09 2014

v5.7.3a

5.7.3.0-alpha http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

24/08 2014

v5.7.3

5.7.3.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

16/05 2014

v5.7.2

5.7.2.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

07/01 2014

v6.0-beta

6.0.0.0-beta http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10
  • ext-mbstring *

 

by Ian Back

php utf-8 pdf

02/09 2013

v5.7.1

5.7.1.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10

 

by Ian Back

php utf-8 pdf

18/07 2013

v5.7.0

5.7.0.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10

 

by Ian Back

php utf-8 pdf

26/01 2013

v5.6.1

5.6.1.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10

 

by Ian Back

php utf-8 pdf

20/11 2012

v5.5.1

5.5.1.0 http://www.mpdf1.com/mpdf/index.php

A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support

  Sources   Download

GPL-1.0+

The Requires

  • php >=4.3.10

 

by Ian Back

php utf-8 pdf