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
mshnmshn 

Image Issue On Sites When Rendering As Pdf

Hi all,

 

We are working on a sites project and we need to show images on a pdf file. We could see the images on visualforce pages actually. But in sites, we can't see what we expect. Is there a specific way to handle this in sites?

 

Thanks.

Avidev9Avidev9

Need some info

  • Where are some images stored ?
  • Attachment or Documents or Static resources ?
mshnmshn

Images are stored as Attachments under Accounts right now but we can change them as Documents if it'd be necessary.

Avidev9Avidev9

So few things I would like you to test

  • Remove the renderAs and check if images appear ?
  • Does the image appear in internal VF pages ?
  • Do you have given access to account for the Site Guest User ?
mshnmshn
  • Yes, image appears when removed renderAs
  • Yes, image appears in internal VF pages
  • No, we are using Authenticated Website (Customer Portal SiteLogin mechanism). Guest users can not enter the site but they can register as new user.
Avidev9Avidev9
What is the image url that you are using in the image tag ?
mshnmshn

Something like that: 

 

https://c.eu2.content.force.com/servlet/servlet.FileDownload?file=00Pb0000000vqDM

 

and this the method that we wrote in controller:

 

public String getGetLogo() {
        Attachment att = null;
        try{
            att = [Select id From Attachment Where parentid=:eg.account_id__c AND name='logo.png'];
        }catch(Exception e){return 'https://eu2.salesforce.com/resource/1373621719000/NoHeaderLogo';}

        return 'https://c.eu2.content.force.com/servlet/servlet.FileDownload?file=' + att.id;
    }

 

Avidev9Avidev9
Can you use a relative URL something like "/servlet/servlet.FileDownload?file=00Pb0000000vqDM"
mshnmshn

I tried but images didn't appear.

 

I think I'm going to give up this idea and try to find a new perspective for my output pdf file.

 

 

Michael_TorchedloMichael_Torchedlo

mshn,

 

There is a possibility that this is a bug.  Please review the following post and see if it applies to your site.  If so, it is a known issue and you should add yourself as an affected user.  Unfortunately, if it is a bug, there is no workaround yet.

 

https://success.salesforce.com/issues_view?id=a1p30000000SvjLAAS

 

 

 

Force.com site that uses custom web address setup does not load static resource CSS when renders a VF page as PDF

VisualForce

Last updated Yesterday ·Reference W-1594833 ·Reported By 2 users

In Review

Summary
Unable to render a static resource or image if a VF page is rendered as PDF. The VF page is invoked from a custom web address that has a CNAME for force.com site.

Repro
- Use renderAs="PDF" in <apex:page> which includes static resource components.
- Exposed the page to the Force.com Site.
- Create a Custom Web Address for the Site.
- Try to access the page from the custom web address.
- The static resource does not render in the pdf

Workaround
- N/A

 

mshnmshn

Thanks for reply Michael,

 

Instead of image tag, I used outputTextField to show image for now. Firstly, I added image as a new rich text custom field. The current problem is that I can't resize image file with css. Actually, it resizes the image on VF page but sites.com.