0

I am generating PDF from HTML using mPDF 5.7. The generated PDF is fine when generated locally, but on server, the images are not getting rendered completely soon enough, and hence PDF is missing all images.

Has anybody encountered this issue? Whats the solution for this?

MSQ
  • 489
  • 5
  • 15

1 Answers1

0

Yes, if the images are PNG, you need to install the php-gd extension, because mPDF needs it to render alpha maps (transparencies of the images).

The issue can be debugged by setting up a debug flag/option for your script, and adding code like

if ($debug) {
  $mpdf->debug = true;
  $mpdf->showImageErrors = true;
}

then you'll be able to see the actual error that caused the missing images which is

mPDF error: IMAGE Error (https://url.to.server/image.png): GD library required for PNG image (alpha channel)

(actually, there will be square icons with an X, like in old InternetExplorer "missing image" style).

You can add GD extension to composer.json, see this answer

ArticIceJuice
  • 155
  • 1
  • 6