function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
billebille 

Problem with backround-image: url in PDF rendered VisualForce page

I have developed a VisualForce page that renders as PDF and have been able to successfully include stylesheets, images, etc.

Unfortunately if I try to include a background image, it does not get displayed. 

 

I have uploaded the image as a static resource, and reference it in my css as follows:

 

.paid {
background-image: url('paid_img');
}

 

The css file is included as  an apex:stylesheet with value {!$Resource.stylesheet}

 

On the Visualforce page I created a div tag with class "paid", but no luck displaying the image. I also tried to use style="background:image url('{!$Resource.paid_img}')" in my div tag, but no luck either.

 

If I create an apex:image tag with value {!$Resource.paid_img} the image gets displayed, so I really don't know what the problem could be.

 

Any help much appreciated!

 

 

Jeremy.NottinghJeremy.Nottingh
Maybe you tried this one already, but you didnt mention it: 

.paid{ 

background-image: url('{!$Resource.paid_img}');

}

 

good luck!

Jeremy

hassabhassab

this is pretty old, but I don't think you can reference static resources in css as you do in vf pages.  you have to find the actual url for the resource, which looks something like resource/timestamp/resourcename - where timestamp is the time you last uploaded it.  It took some doing but I was finally able to reference a custom font using static resource.  the issue being you can never, ever open that resource again without having to change the timestamp in your page, but otherwise it works.  If you need to find the url, just put urlfor formula somewhere in your page, view the page and copy and paste the value, then take it back out of your page.  It's a Gerry Rig solution, but the only way I have been able to find so far...