+ Start a Discussion

Generate PDF from Visual Force page

Hi Team,

I am facing one peculair issue. When I try to download PDF from Visual Page using the URL in one tab after logged into salesforce in the same browser, it is redirecting me to login page again.

Could any one please check and suggest me what could be the cause for it.

Thanks & Regards,
Ajay K DubediAjay K Dubedi
Hi Bsin,

If you try to open a vf page in a new tab salesforce may ask for authentication. Please try opening from Quick find box (Sites or Pages). 

Following code for a vf page worked well for me (displayed account names and their email ids in pdf) when opened from visualforce pages --> page name --> preview:

<apex:page controller="GetCompanyUserInfo" renderAs="PDF">
        <h1>Company User Info</h1>
        <apex:pageBlock >
            <apex:pageBlockTable value="{!companyUserInst}" var="a">
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Email__c}"/>

In sites you can create a new site with 'Active Site Home Page' set to page URL.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Ajay Dubedi
Hi Ajay,

Thank you for the response.

But the issue is observed with only one Visual force page.Its not observed with other visual force pages. The only difference what I see is Sharing settings for the object is "Private" where as for other objects it is "Public Read/Write".

Access to the object whose sharing settings is "Private" is given via permission set.

So when we have permission to access the page, why it is redirecting to login page again.

Thanks & Regards,