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
p1_dfsp1_dfs 

How to display image from document folder in VF PDF page

We are creating a PDF document using Visual Force Page and the document has a logo ( a png or gif image file on header). Currently the image file is a static resource and using merge field the VF page is able to display it correctly. When we do the packaging the resource is also packaged and is getting installed without any issues.

 

Now we want to change the logo at the installed org , as the logo was bundled as static resource it cannot be modified so, we are trying to place the image in a document folder and refer it  in VF page but the image is not displaying correctly .  We have tried using  url for the image but it is not working . Your help or a working example  will be appreciated in resolving this issue.

 <apex:image value="{!$Resource.gii__logo}"/>

We are trying to package the application as managed beta. The static resources gets locked in the target org.

So we are not able to change the logo.

Is there any way we can use a logo file from the document folder in

We already tried using the URL <apex:image url="/document/image/logo.jpg"/>.  But it does not work..

Is there any way to get the URL for the documents within the org itself.


**This is very urgent, **  Your help is much appreciated



okaylah52okaylah52
I am sure you have your reason why changing logo during installation on production..But this is not a good practice changing code during deployment, especially on production environment. Sorry I can't be more helpful.

Maybe the following article can shed some light...

Message Edited by okaylah52 on 09-04-2008 07:17 PM

How about this... (haven't tried if this really works..):
1. In dev sandbox, create a static resource that contains the logo file name and path. Do the same in the production, but with different content/logo name and path.
2. Your programs retrieves the static resource, reads the content (assign to your controller/extension class), then retrieves the correct logo.


Message Edited by okaylah52 on 09-05-2008 01:45 AM
p1_dfsp1_dfs
I want to know if there is way to inlcude the image file from the document in the same org in apex:image tag.
 
The static resource gets locked with managed packaged, but documents  can still be replaced.
 
If some one can tell how to include a image file from the documents in visual forcee page, that will be helpfull
 
thanks
p1_dfsp1_dfs

How about this... (haven't tried if this really works..):
1. In dev sandbox, create a static resource that contains the logo file name and path. Do the same in the production, but with different content/logo name and path.

2. Your programs retrieves the static resource, reads the content (assign to your controller/extension class), then retrieves the correct logo.

Can you please Give some example how I can read the contents of statci resource from control and how to use it in the VF Page

okaylah52okaylah52
Forget about what I said. Here may solve your problem...

1. Create a new Saleforce document, e.g. "bandoneon.jpg".
2. Go to the detail page of the document. Near the "keyword" line, you should see "Click here to view the file". If you hover your mouse pointer of it, you should see the URL, something like "https://na5.salesforce.com/servlet/servlet.FileDownload?file=01570000000toA8". Right-click (assuming you are using MS Windows) the URL then select "Copy link location"
3. In your VF page, write something like...
Code:
<apex:page>
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page.
  <!-- End Default Content REMOVE THIS -->
  <p>Image Bandoneon: <apex:image url="/servlet/servlet.FileDownload—file=01570000000toA8" width="256" height="256"/></p>
</apex:page>

Please note that I've removed "https://na5.salesforce.com" because this is fixed URL and I want to use relative URL.

Hope this helps.

Ron HessRon Hess
that may not work after the app is packaged and installed in a different org.


you may try this, it should work

<apex:image url="{!myimageurl}" width="256" height="256"/>


controller:

 getmyimageurl () { 
    document doc = [  query the document table for the image by exact name  limit 1]
    string imageid = doc.id;
    imageid = imageid.substring(0,15);
    return '/servlet/servlet.FileDownload?file=' + imageid;
}

 
UmapenUmapen

when I get image url the following way, the image is not showing on the sites/portal page? Other part of the page are properly displayed including an image from static Resource?

 

 

<apex:image url="{!myimageurl}" />

 

 

image setting is public public -> Externally available is checked. Image gets displayed properly when I am logge-in?

What other setting do I have to change?

 

JarrettKuljisJarrettKuljis

Thanks Bob Buzzard, your solution of using document storage was just the bump I needed.  Very elegant solution until static resources can be made editable to package subscribers.

MohaMoha
The Image is not showing in public Site/Portal i don't know if "Umapen" you found the solution for that, thanks for the help
zachbarkleyzachbarkley

You need to make the document folder with public access

 

  • Your Name | Setup | Manage Users | Public Groups
  • Create Group
  • Add Default Site Guest User to This group
  • Goto Documents.
  • Edit the Folder that your document is assigned to
  • In the section: This folder is accessible only by the following users, move your new Public Group in the Shared To Column