Activity Forums Salesforce® Discussions How to Create custom PDF Viewer with Save and Email buttons?

  • Abhinav

    Member
    July 26, 2016 at 10:10 am

    Hi Tanu,

    Sure, it can be done. Below is the sample code :

    <apex:page standardController="Amount__c" extensions="AmountCreatePDFController" showHeader="true" tabStyle="Amount__c">
    <apex:sectionHeader title="Amount PDF" subtitle="Amount PDF"/>
    <apex:form >
    <apex:pageBlock >
    <apex:pageMessages id="Messages"></apex:pageMessages>
    <apex:iframe height="400px" width="800px" src="data:application/pdf;base64,{!pdf}></apex:iframe>
    <apex:pageBlockButtons location="bottom">
    <apex:commandButton action="{!save}" value="Save"/>
    <apex:commandButton action="{!cancel}" value="Cancel" />
    </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
    </apex:page>

     

    public class AmountCreatePDFController
    {
    public String pdfurl{get;set;}
    private PageReference pdfPage;
    private Blob pdfBlob;

    public QuoteCreatePDFController(ApexPages.standardController sc)
    {
    initialize(sc.getId());
    }

    public override void initialize(blahId)
    {
    blah = [select whatever__c from Amount__c where id=:blahId];

    pdfPage = Page.Blah_Template;
    pdfPage.getParameters().put('id',blah.id);
    pdfBlob = pdfPage.getcontent();

    }
    public String pdf {
    get {
    return EncodingUtil.Base64Encode(pdfBlob);
    }
    }
    }

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos