Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marjangvg's avatar

MPDF with Laravel Vapor problem

Hello,

I am working on a Laravel 7 project, hosted with Laravel Vapor.

I'm trying to use the MPDF library to convert HTML to PDF.

The problem is, no matter what is the HTML content, i am getting a 'Internal server error' from Vapor.

I have tried with the most basic example from the MPDF documentation:

$mpdf = new Mpdf();

// Write some HTML code: $mpdf->WriteHTML('Hello World');

// Output a PDF file directly to the browser $mpdf->Output();

and it's still throwing an error.

Here is the error output from Vapor:

Fatal error: Uncaught Exception: Error encoding runtime JSON response: Malformed UTF-8 characters, possibly incorrectly encoded in /tmp/vendor/laravel/vapor-core/src/Runtime/NotifiesLambda.php:49 10:41:37 PM

Thanks!

0 likes
1 reply
arefshams2222's avatar

put => charset="utf-8" in a meta tag inside head section of your blade file

Please or to participate in this conversation.