Welcome Guest, Not a member yet? Register   Sign In
problem with dompdf images
#1

[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
#2

[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!
#3

[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.
#4

[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">
#5

[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');
#6

[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');
#7

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

In that case try:

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

[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?
#9

[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?




Theme © iAndrew 2016 - Forum software by © MyBB