mPDF Manual – Troubleshooting

Corrupt PDF file

If you get a message saying “Corrupt PDF file: does not start with %PDF”, it may be because your script - either mPDF or an error in your PHP code - has output an error message. The browser is expecting a file in PDF format, which should start with “%PDF” and instead it gets some text like an error message.

To show error message(s):



$mpdf = new mPDF();

$mpdf->debug = true;




Adding exit

A number of errors can be caused by not explicitly ending your script with $exit;