PDF Images not displaying


Hi Everyone

I’m trying to add some images directly into the template code but when PDF is generated the images are shown as missing (small Red Cross). I’ve used absolute, relative, pointed to images in same directory, root level sub folder, in assets folder but nothing works.

Every src path I’ve used can be found by putting the link directly into the browser but when I enable image debugging the error is always unable to find image.

Not sure if standard html for images works with mPDF or not. Look forward to any help available.

Many thanks


You could debug the invoice logo by putting a var_dump() around it and you can see the path it is using.
It should look like this: <?php var_dump(invoice_logo_pdf()); ?>
But it should be a normal <img> tag.


Good call, I’ll give that a whirl tonight. Cheers Kovah.


Tried using the same location but still doesn’t work. The only way I can get images is by using images stored external to the site. Looks like the only thing I can do at the moment is store them in Dropbox or equivalent and it should be fine. Tried looking through mPDF forums but there was only one post that had similar problem (not using invoice plane by the way) and their resolution was to add what looked like a 100 line php workaround to one of the mPDF files.


That’s a pretty weird bug. Will test this on my set up.


I know this is old, but it’s got no real answer assigned.

I ran into this issue, and by debugging server logs arrived at this solution:

  • upload your image to the /basepath/uploads directory.
  • ensure your Web Server user account has Read access to the file
  • Specify your image location as url('../../../../uploads/filename'); in the PHP template (assuming a template location of /basepath/application/views/invoice_templates/pdf/
If your template location is different, count back the number of directories to the /basepath/, and insert ../ for each level you need to go up to reach the /basepath. I am using this technique to add images within the PHP template and also from the custom-pdf.css file

<techie tl/dr for below> Keeping things local is good for security and accountability. Be safe, y’all!

<Non-techies, This is why you should avoid using “image hosting sites” etc>

Having to host images externally is risky, especially with something like an invoice. Whilst the “emailed” PDF will be fine, if you allow clients to access the invoice online, the invoice assets are redrawn when the “Download PDF” link is clicked. Say you change the image temporarily for a promotion; in the meantime Later that year, Alice is disgruntled with your company, accesses your image host and swaps out the “promotion” image for something indecent.

Client B has lost their invoice, which shows they were entitled to your promotion. Cynthia at Client B decides to retrieve the invoice, clicks “Download PDF” and sees a different angle of Santa’s Sleighbells.

Whilst this risk is still present on a locally-contained system, you have greater traceability. Your clients should have faith in your invoicing system. By keeping the images local, you are showing a greater level of care for your client data by reducing your attack footprint; who wants to have to maintain two systems when they can maintain one!

Congratulations on making it this far. I applaud you


Hi Kovah I am also having the same issue. The dump says this-> string(0) “” . What does it mean.