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
Just in case anyone has the same issues as me:
I changed src="https://" to src="http://" and the images loaded fine.
I also added all CSS inline within a
<style>
instead of loading via<link>
and make sure the CSS
<style>
is in the<head>
not the<body>
Same problem i was facing while i was also set the "DOMPDF_ENABLE_REMOTE=>true" in "dompdf/dompdf_config.inc" but not worked.
One thing worked for me change the src for images/css from absolute to relative and things done.in this case i have all the css/images on my server.
Can you reach those URLs in your web browser on the machine that you're using to open the PDF? If not, the PDF reader won't be able to either.
I suspect that the "localhost" domain means that those URLs are only visible from the web server that generated the PDF. You need to output a url like http://example.com/dompdf/image.jpg
(To step around this issue, bear in mind that there are good reasons not to use remote images. The document will look bad if the viewer is not connected to the internet, for example. Is it possible to just embed the images directly in the document?)