• VPd
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi All,

I have a visualforce page to render as PDF. This page has few images with total size as 5MB but it throws view state limit exception. The salesforce documention says "The maximum total size of all imagesincluded in a generated PDF is 30 MB". I don't have any controller variable(dynamic values) to show on the page. it all has static text, CSS and images.

Not sure why this view state limit hits given that the salesforce allows total image size as 30MB and imanges to show in my case is just 5MB. Any help or pointer on this would be greatly appreciated.

Thanks,
  • November 08, 2017
  • Like
  • 0
Hi All,
I have a lighting action button on lead standard page with action type as visualfroce page. When the button is clicked and visualforce is loaded, I need to generate a PDF with some lead data and save this PDF as an attachment. It is working fine in a dev org with Summar17 release but the same logic and piece of code does not work in a sandbox with Winter18 release and creates a blank PDF in attachment.
Any help would be a great relief to figure out if this is a code issue or an issue with salesforce latest release.

Dummy Code:
<apex:page standardController="Lead" extensions="ProposalController" docType="html-5.0" showHeader="false" sidebar="false" standardStylesheets="false" showQuickActionVfHeader="false">
<apex:slds />
<head><script> window.onload = function() {createProposal();} </script> </head>
<body>
   <apex:form id="t" >
<apex:outputPanel id="outerPanel">
  <apex:outputPanel rendered="{!isAttachmentCreated}">
       <!-- Showing attachment link here -->
</apex:outputpanel>
</apex:outputPanel>
<apex:actionFunction name="createProposal" action="{!generateProp}" rerender="outerPanel" />
</apex:form>
</body>
</apex:page>
Controller
public ProposalController(ApexPages.StandardController stdController){
     leadObj = (Lead)stdController.getRecord();
    isAttachmentCreated = false;

}
public void generateProp(){
   PageReference pdf = Page.GenerateProposal;
  pdf.getParameters().put('id',leadObj.id);
  Blob pdfPageBlob = pagePdf.getContentAsPDF();
  a = new Attachment();
  a.Body = pdfPageBlob;
  a.ParentID = leadObj.id;
  a.Name = 'Test Attachment';
  a.Description = 'TestDescription1';
  insert a;
  isAttachmentCreated = true;
}
Page to render as PDF
<apex:page renderAs="pdf" standardController="Lead">Name: {!Lead.name}Source: {!Lead.leadsource></apex:page>
  • September 22, 2017
  • Like
  • 0
Hi All,

I have a visualforce page to render as PDF. This page has few images with total size as 5MB but it throws view state limit exception. The salesforce documention says "The maximum total size of all imagesincluded in a generated PDF is 30 MB". I don't have any controller variable(dynamic values) to show on the page. it all has static text, CSS and images.

Not sure why this view state limit hits given that the salesforce allows total image size as 30MB and imanges to show in my case is just 5MB. Any help or pointer on this would be greatly appreciated.

Thanks,
  • November 08, 2017
  • Like
  • 0