HTML not rendering in mPDF on live server, but $mpdf->Image() works

12 hours ago 3
ARTICLE AD BOX

I'm facing an issue with mPDF where HTML <img> tags are not rendering on my live server, but they work perfectly on localhost.

What works:

Using direct mPDF method:

$mpdf->Image('https://example.com/images/test.png', 10, 10, 50);

This displays the image correctly on the live server.

What doesn't work:

Using HTML:

<img src="https://example.com/images/test.png" width="100">

When I pass this HTML into mPDF:

$mpdf->WriteHTML($html);

The image does NOT appear on the live server.

Environment:

mPDF version: 8.2.30

PHP version: 8.2.0

Works on localhost (XAMPP), fails on live server

What I've checked:

Image URL is accessible via browser

No errors thrown by mPDF

File permissions seem fine

Question:

Why does <img> not render in mPDF on live server, while $mpdf->Image() works?
Are there specific settings (e.g., allow_url_fopen, SSL, or base path issues) that could cause this?

Any help would be appreciated

Read Entire Article