We are getting plagued with this which started in April on working server. Everything was fine with our application until the customer reported that PDFs were no longer displaying the images.
Our PDF is generated via a HTML render first. When the HTML render is displayed the Image shows correctly. Also the image shows correctly if the image URL as noted in the mPDF is copied and pasted into a new tab.
However... If we load the image from a DIFFERENT DOMAIN then the image is rendered correctly. loading the image via absolute path, relative path or URL path all result in this error:
mPDF error: IMAGE Error (http://www.aibsonline.co.uk/logo.gif): Could not find image file
But, as you will see the logo url works when pasted. File permissions have been tested (which is why it is in the root) as standard and up to 777. Server is a Linux server in both cases we have seen so far.
HTML Code that renders the logo:
<div id="logo_wrapper" class="left">
<img width="107" height="76" src="<?php echo base_url('logo.gif'); ?>" />
</div>
At a real loss with this one and it is beginning to affect more and more clients.
Any help gratefully received.
UPDATE
The image renders if the rendering code and the image are in the same directory and we do NOT use an absolute path, eg.
<img width="107" height="76" src="logo.gif" />
I had a similar issue and I solve by following:
1.Check if gd library is installed and enable in your php ini file. If not install gd library.
2.Turn on debug variable
3.Try inter-changing absolute/relative path for the image
Hope this helps.
Just make sure that you have image related functions in your PDF class file. Like parsejpg, parsepng, parsegif etc...
I ran across this issue today. My problem was that the domain name I was using didn't resolve back to the server when accessed from the server. I added an entry to the hosts file on the server, and images started showing.
Your equivalent hosts file entry of what fixed my problem would be:
Or otherwise ensure that www.aibsonline.co.uk resolves to your server in the DNS that your server uses.
It appears that mPDF accesses images as a cURL web client, so DNS on the server needs to be configured correctly to refer back to itself.
I was running into the same issue. mPDF was running DOG SLOW and would end up just displaying a "Cannot find image file" error. After
I found that the image file in question was corrupted somehow. I downloaded the image to my local computer, opened it up with an image editor (Paint.NET in this case), re-saved it as a .gif file and uploaded it to the server again. That seemed to fix it. Your mileage my vary.
Also, for what its worth, I had to use
images/image.gif
instead of the file path/images/image.gif
.With same issue, I found that get_headers() returns:
Provider says this was due to web firewall, because the request was badly formed and the user_agent not set.
An
ini_set('user_agent', 'Mozilla/5.0');
solved the problem.In a WordPress plugin using mpdf, mpdf doesn't use WordPress http classes and doesn't set user_agent. I solved this by adding in mu-plugins: