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
Vikash Kumar MandalVikash Kumar Mandal 

getcontentasPDF is not working from site guest user

Hi All,

I have made a visualforce page and I want to render it as pdf and store in one field. I have created the apex class and using future callout for the generation of PDF. When I tried from the backend then the PDF is generating correctly but at the same time when I am trying from the site guest user then the content is not rendering on PDF. It is generating only the blank PDF. 

Please help me with this. How to resolve this issue.

Thanks!
Ajay K DubediAjay K Dubedi
Hi Vikash,

There might be chances that you are missing the required permission of sObject for this guest user.

So first check your guest user have all required permission.

Then you need to make sure The Guest User is able to directly access the visualforce page which you render as PDF. So in order to provide access to it you have to construct a URL for it. If the Guest User finds the path through its URL it will support the call getContentAsPDF(); and values will be present in the PDF.

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

Thanks,
Ajay Dubedi
Vikash Kumar MandalVikash Kumar Mandal
Hi, Ajay

I have given all the permission to the guest user. and I am using 
PageReference pdf = Page.TestLetter;
pdf.getParameters().put('oppId',oppId);
but it is not working.

Thanks!
Deepali KulshresthaDeepali Kulshrestha
Hi Vikash,

I think you have to change your URL please put site URL in the page reference URL with the page name I also face this problem once.
This is because the URL of the Page for the Site is changed and it can not access the page so it returns a blank pdf.
Please try this, if any other query feels free to ask.

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

Thanks and Regards,
Deepali Kulshrestha