PHP library generating PDF files from UTF-8 encoded HTML
Version 8.1.0 contains cleanups, fixes, a few code refactorings most importantly leading to a new experimental feature of internal services container.
Note: as this is an experimental feature, key names and interface names for container services can and will change in future versions.
A new optional parameter has been added to the Mpdf class constructor. It expects an instance of \Mpdf\Container\ContainerInterface
(which is compatible and in mPDF 10.0 will be replaced by proper PSR-11 ContainerInterface
), which can now override two internal services: HTTP client, and local filesystem resource loader.
The Mpdf\Http\ClientInterface
, also compatible with and planned to be upgraded to PSR-7 HTTP Client, can be used by the httpClient
key of the passed Container and used to restrict remote HTTP calls, implementing HTTP requests cache, altering incoming responses etc. With a simple bridge, it can be used to leverage already used HTTP client in an existing application, such as Guzzle or Symfony HTTP Client.
By default, a simple implementation based on curl (if available) or sockets (as a fallback) is used.
The simple Mpdf\File\LocalContentLoaderInterface
is used to load local content. Custom implementation by the container key localContentLoader
can implement restrictions for certain directories of the filesystem to prevent outside HTML code loading unwanted files. Default implementation uses a simple file_get_contents call.
Unwanted stream wrappers are handled for all local and remote content fetches in an encapsulating internal service.
Thank you for any work you put into mPDF - refactorings, bug fixes, new feature requests.
We also welcome any donation.
Hope number of downloads will keep rising!
Version 8.0.0 contains code cleanups, a few minor fixes and features, and most importantly bump of internal dependency of the FPDI library to version 2.
This introduces a few breaking changes.
Method SetImportUse
has been removed and ImportPage
changed case to importPage
and has a new signature:
public function importPage($pageNumber, $box = PageBoundaries::CROP_BOX, $groupXObject = true)
Library generating QR codes has been split to a separate package mpdf/qrcode
. This reduced package size by about 6 MB. The library will raise an exception hinting to install the package with composer when needed and not present.
Complete changeset can be found in changelog and commit history.
mpdf/qrcode
with composer and you're setThank you for any work you put into mPDF - refactorings, bug fixes, new feature requests.
We also welcome any donation.
Hope number of downloads will keep rising!
Version 7.1.0 contains large internal code cleanups, big refactoring of HTML tags handling (big kudos to @machour), fixes of many reported PHP notices, and other fixes (!important
breaking size conversion, logger changes in internal services).
As for new features, orientation
constructor $config
array can be used to specify page orientation (thanks, @Dasc3er). Headers and footers can be now positioned absolutely (thanks, @jakejackson1). QRCode can have a custom color (@achretien).
Minor version bump justifies an added dependency of myclabs/deep-copy
package needed for the fix of TOC pagination.
Complete changeset can be found in commit history.
Thank you for any work you put into mPDF - refactorings, bug fixes, new feature requests.
We also welcome any donation.
It seems almost unbelievable to get a million downloads since the version 7.0, in a half a year. Thanks for using mPDF!
Version 7.0 is a large code cleanup release with introduction of namespaces, code structure cleanup, introduction of PSR compliant file structure and autoloading. It requires at least PHP 5.6 and is tested with up to PHP 7.2.
See CHANGELOG for the complete list of changes, fixes and enhancements and README for the quick tour.
See a documentation chapter on upgrading.
Composer is now the only officially supported installation method. There are no pre-packaged library archives.
All classes moved under Mpdf
namespace. Main class renamed to Mpdf
. Now accepts single $config
array parameter in its constructor.
Most side-effects of the former mpdf.php file were removed.
Progressbar and graph features were removed.
All global constants were removed in favor of class constants or configuration directives.
All errors are now thrown as exceptions extending \Mpdf\MpdfException
.
Support for up to PHP 7.2. File & directory structure cleanup, PSR-4 autoloading. Refactoring of many easy-to-separate code portions.
Support for multiple font directories. PDF/A-3 associated files + additional xmp rdf support.
Introduced PSR-3 logging.
There can be a bit of confusion about the library name casing with introduction of PSR-compliant class naming.
The name of the library is still mPDF.
Main namespace is Mpdf
, FQN of the main class is \Mpdf\Mpdf
, packagist package is mpdf/mpdf
.
We welcome any donation.
The mpdf/mpdf Packagist package surpassed the 2 milion downloads some time around October 14th. Thanks for showing us the appreciation this way.
The v7.0 is far from perfect. It retained many of 6.x branch flaws, incomplete CSS support, far-from-perfect architecture.
The main goal of this version was to start giving the code a clean and defined structure and slowly starting decomposing it to smaller parts. This helped add support for newer PHP versions.
There are many things to be done, some of them are laid out in the Issues tracker here on GitHub.
mPDF now should follow semver. All reported notice and warning fixes will be continually solved in patch releases, smaller new functionality can be added in minor releases. Breaking changes will have to wait for major releases, in this case v8.
Many thanks to all small contributors to the library mentioned in the changelog, sorry to anyone who was missed.
Special thanks to @Klap-in for his extensive work on the documentation.
See CHANGELOG.txt for list of changes, fixes and enhancements.
Composer package mpdf/mpdf is a recommended installation method:
$ composer require mpdf/mpdf 6.1.0
You can also choose from a variety of pre-packaged files which contain pregenerated autoload library from Composer, so you would then require autoload.php
file:
<?php
require PATH_TO_MPDF . '/vendor/autoload.php';