Codeigniter mpdf is not displaying images in live server - php

I have used mpdf for my codeigniter Project to print ticket with header image and it is working in my local machine while I moved source to test server, the images are not displaying in generated PDF.
Is the Permission issue? Is the invalid SSL issue?

I faced the issue once. You may use the image extension .jpg. It seems mpdf in some live server only accepts .jpeg images. Check with .jpeg images
Note: Don't just manually change the extension. The mime type should be of jpeg image(image/jpeg).

Related

can't upload image with roxyfileman with php in iis8

I used roxyfileman with tinymce4 in lot of project on wamp and server. but this time I want to run my php code on IIS8.5 , but when i want to upload image the roxyfileman can't do it for me and just give me a simple "error" message. I also can't rename a uploaded image too.any body have any idea about this? how can i resolve this problem?
i check IIS mime type and json mime type were added.
after on day struggling i change my destination folder permisision for iis user , and the problem sloved. and now I can upload iamges and rename them.

Does ssl block imgur from getting image dimensions?

I'm using php GD library to create an png file, I'm saving it to my server.
URL for the image is
https://server.com/signature/123.png
My problem is I can't upload that image to imgur, I get this error
This issue also occurs on other image uploading sites / forums
However if I decide to download the image to my desktop and upload it to imgur it seems to work. Anyone has an idea on why this is happening?

dompdf image not found on live server

After several hours of searching, I am still unable to resolve this issue. I am having a problem with displaying images in a PDF file generated by dompdf library.
I have an editor tinyMCE where a user can upload images, edit his page, and see a preview in PDF format with a Button press.
One important thing here: I am using 'convert_urls : true' in tinyMCE's configuration which converts the image src = "https://mysite.com/public/images/image_name.png", necessary for the PDF library to display them.
I set the required dompdf configurations:
def("DOMPDF_ENABLE_REMOTE", true);
Here I found that it will appear after changing the attached CSS with a dompdf like:
img { display:block }
All still in vain.
Note: Everything is working fine on localhost. But on the staging server, I get a message box having a cross inside it saying "image not found" and displaying the image path. When I click on that path, the image is already there on my server. I wonder why dompdf is giving me this message?
I already faced same kind of issue. solution is very simple when Dompdf does not accept url with http format. Try with full document root.
Instead of using https://example.com/public/images/image_name.png try with /var/www/mysite/public/images/image_name.png
Use a absolute path for external css and images than live path! its worked for me also

mPDF not rendering images (mPDF error: IMAGE Error Could not find image file)

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 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:
127.0.0.1 www.aibsonline.co.uk
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 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
$mpdf = new mPDF();
$mpdf->showImageErrors = true;
3.Try inter-changing absolute/relative path for the image
<img src="http://someDomain/directory/image.jpg">
<img src="./directory/image.jpg">
Hope this helps.
With same issue, I found that get_headers() returns:
"HTTP/1.1 412 Precondition Failed"
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:
global $wp_version;
ini_set('user_agent',apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ));
I tried all other answers here but for me, only adding
$mpdf->curlAllowUnsafeSslRequests = true;
fixed the issue.
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
checking to make sure the image is actually there
checking the permissions on the file
checking all of the error logs on the server
combing through the documentation on mPDF
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.
Just make sure that you have image related functions in your PDF class file. Like parsejpg, parsepng, parsegif etc...
I have password protected server (.htaccess / .passwd) and after some research I understand that mPDF using HTTP to get the images, but server blocks the images from the public because of password protection.
After removing password protection I had ssl certificate issue, and I enable usafe requests and it starts working
$mpdf->curlAllowUnsafeSslRequests = true;
Also you can always enable debug modes and follow the error messages
$mpdf->showImageErrors = true;
$mpdf->debug = true;

mpdf generates pdf without images

I use mpdf for a php project but I am having difficulties generating pdf file with images. it displays the pdf file correctly on browsers but after I save the pdf file it doesnt display the images. I tried it with different browsers/OS and the result is little bit strange to me. it works on very browser and displays local pdf file correctly on linux machine. mac and windows it displays images on every browser but when I save the pdf file it doesnt display the images on local pdf. do you have any idea how to solve this problem.
Thanks
you have to use absolute linking, starting all the way at the top with the domain name.

Categories