DOMpdf images not showing on live server

8,834 views
Skip to first unread message

Iain

unread,
Jan 25, 2012, 7:06:30 PM1/25/12
to dompdf
I've created an application which outputs a PDF report based on an
HTML page using DOMPDF.

This works fine on my test server, but when I've migrated it over to
the live server, none of the images show in the PDF. It's not showing
a RED X - just nothing there at all.

I've checked that the new server meets the requirements using the
config tool, and I've enabled the "leave images in temp" debugging
option, and nothing is being created in the the temp directory.

I've also checked the allow remote option is on.

Any ideas what might have changed to stop it from working?

Iain

unread,
Jan 23, 2012, 9:48:54 PM1/23/12
to dompdf
I've successfully got DOMpdf producing PDFs on my test server, but
when I moved it over to the live server, the images don't show.

Some background information:

1. On live server, all the "setup" boxes are green apart from TTF2AFM
Not readable, and APC not present
2. My temp dir is writable, and nothing is appearing in it, despite
having set DEBUGKEEPTEMP to true
3. There are no red crosses - the images are just empty
4. When I do a normal HTML render of the page in my browser, images
show up
5. DOMPDF_ENABLE_REMOTE is true
6. I'm using absolute paths to images

All the images were showing fine on the other server, so not sure
what's happened...please advise!

Thanks

Iain

Alvin Casco

unread,
Feb 4, 2012, 3:05:04 PM2/4/12
to dompdf
Hi Iain,
Same thing was happening to me. I found that on my localhost all was
well. Then migrated my development to a webhost with 1and1.co.uk
and no images. I've searched for a solution, but one thing worked for
me.

As a lot of advice from others specifying <img src="var/www/etc" />,
well fair enough if you have root access, but if you've only got a
hosting package then
these are the steps I made to get my images to appear:

1. Get the document root for your hosting package, not the part of the
domain http://domain.co.uk!
the best way to get this is via phpinfo(), just create a file with
whatever name you want filename.php and then upload that to the web
root /
Look for the line where it says document root. I found that with
1and1 hosting it looks something like the following:
/kunden/homepages/18/d12345678902/htdocs basically this is
the http://domain.co.uk
don't forget to delete that file with the phpinfo(); in it

2. To get your images working place that in the img tag <img src="/
kunden/homepages/18/d12345678902/htdocs/path/to/image" />

3. With that my I went back and turned off the DOMPDF_ENABLE_REMOTE
i.e set to false, apparently in the documentation there are security
issues
with this turned on. the only thing that I have activated in the
dompdf_config.custom.inc.php is the /tmp directory.
I still have a problem with file not being written to the tmp
folder! Hopefully some one out there can give a step by step guide to
that.

Anyway, whether you've already solved your dilemma or not, I hope this
can help others.

Happy coding everyone,
Alvin

BrianS

unread,
Feb 7, 2012, 10:44:55 PM2/7/12
to dom...@googlegroups.com
FYI, for anyone else who runs into this problem (ref: DOMPDF images not showing on new server):

It appears that if your CSS specifies your images as display:block, DOMPDF won't show them sometimes. Have changed my code so that it uses a pdf-specific CSS file without that it.
 

BrianS

unread,
Feb 7, 2012, 10:50:08 PM2/7/12
to dom...@googlegroups.com
On Saturday, February 4, 2012 3:05:04 PM UTC-5, Alvin Casco wrote:
Hi Iain,
Same thing was happening to me. I found that on my localhost all was
well. Then migrated my development to a webhost with 1and1.co.uk
and no images. I've searched for a solution, but one thing worked for
me.

As a lot of advice from others specifying <img src="var/www/etc"  />,
well fair enough if you have root access, but if you've only got a
hosting package then
these are the steps I made to get my images to appear:

1. Get the document root for your hosting package, not the part of the
domain http://domain.co.uk!
    the best way to get this is via phpinfo(), just create a file with
whatever name you want  filename.php  and then upload that to the web
root /
    Look for the line where it says document root. I found that with
1and1 hosting it looks something like the following:
    /kunden/homepages/18/d12345678902/htdocs     basically this is
the  http://domain.co.uk
    don't forget to delete that file with the phpinfo(); in it

2. To get your images working place that in the img tag <img src="/
kunden/homepages/18/d12345678902/htdocs/path/to/image" />

Is your host chroot user accounts perhaps? Just curious, were you getting empty space or the red X?
 
3. With that my I went back and turned off the DOMPDF_ENABLE_REMOTE
i.e set to false, apparently in the documentation there are security
issues

So long as you are configured correctly you should have no problems. Though it's always safer to turn off features you don't need. I'm hoping that we'll be able to post a document regarding securing your setup sometime in the near-ish future.
 
    with this turned on. the only thing that I have activated in the
dompdf_config.custom.inc.php is the /tmp directory.
    I still have a problem with file not being written to the tmp
folder!  Hopefully some one out there can give a step by step guide to
that.

Presumably you've checked whether or not you have read/write access to /tmp? You can always specify a different folder (say, one under your account) to see if you have any better luck.
Reply all
Reply to author
Forward
0 new messages