CodeIgniter Forums
problem with dompdf images - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: problem with dompdf images (/showthread.php?tid=17875)



problem with dompdf images - El Forum - 04-18-2009

[eluser]afsar[/eluser]
HI friends,

I used the dompdf plugin with ci to generate pdf. It worked fine for normal text and proper image srcs like <img src="hi.gif">. if img src is like <img src ="http://photos.mris.com/usr/sv9/photos3/image/0001/0005/1945"> it is not displaying the image in the pdf. normal view page is displaying the image. There is any way to print images in the pdfs.

thanks in advance,
afsar


problem with dompdf images - El Forum - 04-18-2009

[eluser]Mike Ryan[/eluser]
Hi Afsar,

dompdf does not work with remote images. You will need to download the image first (maybe with copy), then include the local file in your pdf. Remember to delete the image after you have finished with it!


problem with dompdf images - El Forum - 04-20-2009

[eluser]afsar[/eluser]
i follwoed this code to get the image stored and later displayed it.
$K=$record['Picture'];
$sno=1;
$contents = file_get_contents($K);
$fp = fopen('images/'.$sno.'.jpg.', 'w');
fwrite($fp, $contents);
fclose($fp);.

thank you forum team for all.


problem with dompdf images - El Forum - 09-13-2010

[eluser]emorling[/eluser]
The SOLUTION for including images in domPDF.

It doesn't matter that the images display in your browser.

You must include the server path to the image.

In my case it was this (img resides in the same folder as my system folder):

<img src="./img/pdf/logo.png">


problem with dompdf images - El Forum - 10-25-2010

[eluser]Ace_ov_Spade[/eluser]
I'm having problem for adding images. it may be a path issue. it shows empty image in the pdf but shows correctly in browser. maybe I'm missing something very simple :down: .

Code:
$html='<img src="/my-image.jpg" />';
pdf_create($html, 'filename');



problem with dompdf images - El Forum - 10-25-2010

[eluser]Ace_ov_Spade[/eluser]
I’m having problem for adding images. it may be a path issue. it shows empty image in the pdf but shows correctly in browser. maybe I’m missing something very simple.

Code:
$html='<img src="/my-image.jpg" />';
pdf_create($html, 'filename');



problem with dompdf images - El Forum - 10-25-2010

[eluser]emorling[/eluser]
is my-image.jpg in the root?

In that case try:

$html='<img src="./my-image.jpg" />';
pdf_create($html, 'filename');


problem with dompdf images - El Forum - 10-25-2010

[eluser]Ace_ov_Spade[/eluser]
I tried with that. doesn't work Sad

my app is in wamp in my local machine. actually images works fine with browsers. but doesn't show in PDF. is there a different way to add image in dompdf? or can usual html tag do it?


problem with dompdf images - El Forum - 10-25-2010

[eluser]Ace_ov_Spade[/eluser]
I tried it. doesn't work Sad

simple html tag [img] can add image to pdf? or is there any other way for it?