• Aaron Wallace
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies

I am trying to create a pdf from the Lead Object in Salesforce using the Apex language. I am able to create the pdf and attach it to the Current Lead but it does not pull in any of the information from the Lead into the PDF itself.
Page Code:

<apex:page standardController="Lead" renderAs="pdf" showHeader="false"> 
    <apex:stylesheet value="{!$Resource.pdfCss}"/> 
    <apex:panelGrid columns="1" width="100%"> 
      <apex:outputField value="{!Lead.Name}" styleClass="companyName"/> 
      <apex:outputText value="{!NOW()}"></apex:outputText> 
    </apex:panelGrid> 
</apex:page>

Class Code:

public class attachPDFToLead { 
    private final Lead a;
    public attachPDFToLead(ApexPages.StandardController standardPageController) 
       { 
          a = (Lead)standardPageController.getRecord(); 
       } 

public PageReference attachPDF() {
    PageReference pdfPage = Page.PDF; Blob pdfBlob = pdfPage.getContent(); 
    Attachment attach = new Attachment(parentId = a.Id, Name = 'insuranceVerification.pdf', body = pdfBlob); 
    insert attach; 
    PageReference pageURL = new ApexPages.StandardController(a).view(); 
    pageURL.setRedirect(true); return pageURL; 
} 
}

I am trying to create a pdf from the Lead Object in Salesforce using the Apex language. I am able to create the pdf and attach it to the Current Lead but it does not pull in any of the information from the Lead into the PDF itself.
Page Code:

<apex:page standardController="Lead" renderAs="pdf" showHeader="false"> 
    <apex:stylesheet value="{!$Resource.pdfCss}"/> 
    <apex:panelGrid columns="1" width="100%"> 
      <apex:outputField value="{!Lead.Name}" styleClass="companyName"/> 
      <apex:outputText value="{!NOW()}"></apex:outputText> 
    </apex:panelGrid> 
</apex:page>

Class Code:

public class attachPDFToLead { 
    private final Lead a;
    public attachPDFToLead(ApexPages.StandardController standardPageController) 
       { 
          a = (Lead)standardPageController.getRecord(); 
       } 

public PageReference attachPDF() {
    PageReference pdfPage = Page.PDF; Blob pdfBlob = pdfPage.getContent(); 
    Attachment attach = new Attachment(parentId = a.Id, Name = 'insuranceVerification.pdf', body = pdfBlob); 
    insert attach; 
    PageReference pageURL = new ApexPages.StandardController(a).view(); 
    pageURL.setRedirect(true); return pageURL; 
} 
}