mPDF Manual – Troubleshooting

Blank screen

If you get nothing but a blank screen on your browser, it may be because there is a script error. Turn on debugging at the start of your script:

<?php
// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';

try {
    $mpdf = new \Mpdf\Mpdf();
    $mpdf->debug = true;
    $mpdf->WriteHTML("Hello World");
    $mpdf->Output();
} catch (\Mpdf\MpdfException $e) { // Note: safer fully qualified exception 
                                   //       name used for catch
    // Process the exception, log, print etc.
    echo $e->getMessage();
}

See also Known issues and Corrupt PDF file.


localhost problems / Vista 64 bit

Since updating to Windows Vistax64bit for development, all files containing images or external stylesheets crashed or timeout.

See the useful thread at http://www.wampserver.com/phorum/read.php?2,28291

To generate images and retrieve external stylesheets, mPDF needs to access files using fopen() etc. Changing localhost to 127.0.0.1 resolved the problem.

Generating graphs with JPGraph

JPGraph outputs error messages as images generated by the script. If the error message is “out of memory” then you just get a blank screen. Try increasing your memory_limit.

Fork me on GitHub