background image doesn't show in dompdf

Refiking picture Refiking · Jul 26, 2010 · Viewed 14.9k times · Source

For some reason, the background image doesn't show in dompdf no matter what I try. I've put the direct url as well. None of them worked. Can someone with dompdf experience tell me what I need to do?

It's important to note that other images appear just fine. It's only the bakground images that are causing issues. Here is one of the background images:

body{
 font-size:15px;
 background:url(bg.jpg) repeat-x bottom left;
}

Answer

BrianS picture BrianS · Jul 30, 2010

Using DOMODF 0.5.1? It's probably having trouble parsing the background shorthand. You could try breaking up the generic background property into the specific properties:

background-image: url(bg.jpg);
background-repeat: repeat-x;
background-position: bottom left;

I also found that sometimes I had to supply a full URL (http://example.com/bg.jpg).

The handling of this property is a little buggy in that version of DOMPDF. You might consider upgrading to the 0.6.0 code base (currently at beta 1). It has a number of improvements over the previous release.