On my server pdf generated via dompdf was not displaying images. Because they are remote url images.(local images are working fine) then I come to know that it needs some settings to render remote images.
allow_url_fopen = true => i can not as server control is not in my hand.(and no one will suggest to do this due to security reasons)
read/write access to the DOMPDF_TEMP_DIR (already have this)
DOMPDF_ENABLE_REMOTE = true (already have this)
So to sure the issue of allow_url_fopen, I set false in my localhost which is now giving the same output as server.
So, now the issue is now I want to display remote images in PDF with allow_url_fopen = false
- I tried almost 5-10 unique ways to do this.
- I tried to display image in php file (via setting headers) and then displaying the php link in pdf
- I tried to display image via absolute path to php too but nothing worked.
- I tried via getting image via curl in a function and then displaying it in a php file ...but no luck.
Is there anyone can suggest me how can I display image in pdf please. The error I am always getting is ...
Image not found
http://localhost/dompdf/image.php
and
Image not found
http://localhost/dompdf/image.jpg
Try
I had the same problem, dompdf image not found on live server
I found its solution, you just need to double check the image path,
Considering your live server image path
You just need to change it to,
Note: Make sure that, all settings are same as you have already made.
I hope this will help you.
There are two things to take care of.
If using image from same server then use full directory path e.g.
/var/www/html/project_folder/images/logo.jpg
List item Use
JPEG
image instead ofpng
or other types.dompdf doesn't currently have a mechanism for distinguishing between a local and remote domain, so any URL that starts http://... is treated as remote. Plus, any image that uses a PHP-based intermediary (like pic.php) can't use a local path because the PHP will not be parsed unless you go through a web server.
It's a difficult prospect, but your pages are generated dynamically. So I see two options:
Since you've already worked out getting the image using curl you should be able to implement either one of these.
I think you could add this
to change url for image
Go to the dompdf_config.inc.php file and set the variable DOMPDF_ENABLE_REMOTE to TRUE ...