mPDF Manual – Troubleshooting

Known Issues

Script ends with no output

1. Use a try/catch block for a \Mpdf\MpdfException to find out more:

<?php
try {
$mpdf = \Mpdf\Mpdf();$mpdf->WriteHTML('Hello World');
// Other code
$mpdf->Output(); } catch (\Mpdf\MpdfException$e) { // Note: safer fully qualified exception name used for catch
// Process the exception, log, print etc.
echo $e->getMessage(); }  2. Enable error_reporting in your development environment or look into PHP error logs. 3. Enable debug mode and/or Inject a Psr\Log\LoggerInterface and see logs Crashing with no error message whatsoever Ensure mbregex is enabled as part of mbstring. Apparently this is enabled by default when you enable mbstring in most cases, however with cPanel and some other non-standard environments this might not be the case, so people have to explicitly look for and enable mbregex (i.e. compile PHP with --enable-mbregex. Blank pages or some sections missing If you pass a large chunk of code to WriteHTML() whether as CSS styles or the main HTML code, you may get a blank page output, or that section of code missing. The PHP function preg_replace() has a maximum string length it will parse (by default this is often about 100000 characters). Over this, PHP silently returns a null value. So long strings of code will be replaced by nothing! You may be able to increase the value of pcre.backtrack_limit at runtime if your system allows; alternatively, break your HTML into chunks and pass them one at a time to WriteHTML() pcre.backtrack_limit is configurable from PHP ≥ 5.2.0 The default value was increased from 100,000 to 1,000,000 from PHP ≥ 5.3.7 ini_set("pcre.backtrack_limit", "1000000");  Keep-with-table If use_kwt (“keep-with-table”) is set, and a heading element precedes a table inside a div with border/background set: it does not work e.g. <div style="border: 1px solid #000000; background-color: #EEEEFF;"><h2>Title</h2><table...  Program dies with no error message when generating a large PDF file A timeout due to Apache configuration TimeOut will cause the script to terminate with no error message, despite increasing the PHP time limit etc. See also Blank screen for a bug when using localhost. Problems fixed from mPDF ≥ 5.0 Indic Fonts - ASCII characters The Indic fonts (added mPDF 4.0) do not contain the basic ASCII characters: a-z,A-Z, and in some: ' and $.

The font files have been edited to add these characters if you are using embedded font subsets (so all ASCII chars show), but they will not be available if you are not using subsets. In this case you need to mark up HTML text with lang or font-family.

With some SVG images, Adobe Reader 7 throws an error - “Problem with Type 3 font, form or pattern”.