Find your content:

Search form

You are here

Is it possible to use images in Visualforce generated PDFs which are not static resources?

 
Share

I'm trying to generate a Visualforce PDF (renderAs) with a variety of images from different sources includes Salesforce Attachments and Documents, as well as third party sites. So far I've only been able to display images stored as static resources, or stored in zipped static resources.

Is it possible to use images which are not stored as static resources in Visualforce-generated PDFs?


Attribution to: paul

Possible Suggestion/Solution #1

As in a standard img src="http://someurl.com" - I don't believe so. Testing it with either http or https in the image source results in a broken PDF image for me.

Edit: The other comments are correct, this works if Remote Site Setting is setup. My test earlier was cached.


Attribution to: joshbirk

Possible Suggestion/Solution #2

We've had a little bit of success putting regular image URLs into our VisualForce PDFs by just using ''. However, there are some images that just won't generate properly, so we've had to set them up as static resources and haven't been able to get them to render without doing it that way. We thought it might have something to do with SSL or the file types, but don't think that's the case. Anyone else have experience with this?


Attribution to: Jon J

Possible Suggestion/Solution #3

This should be possible: we do this in FinancialForce Accounting via the servlet.fileDownload URL that salesforce provides for downloading documents to include company logos on PDF financial documents.

The trick is that any external URLs you want salesforce to make a HTTP(s) call to need to be defined under Setup > Security Controls > Remote Site Settings. Make sure the protocol (HTTP vs HTTPS) matches the image link!

A followup edit that it appears that the older PDF rendering engine (pre APIv24?) does not pass a session ID when requesting images from salesforce documents. I made the image externally available and it worked - note that this changes the URL from servlet.FileDownload to servlet.ImageServer as well. V25 seems to pass the session ID as expected so far.


Attribution to: ca_peterson

Possible Suggestion/Solution #4

Yes, you can. I've done it. The (undocumented) trick is that you need to have Remote Site Setting records setup for the domains where the external URLs are hosted.


Attribution to: hemmeter

Possible Suggestion/Solution #5

Image uploaded as document can also visible in pdf page


Attribution to: Eager
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/23

My Block Status

My Block Content