Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

php - Dompdf remote image is not displaying in pdf

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try

$options = new Options();
$options->set('isRemoteEnabled', true);
$dompdf = new Dompdf($options);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...