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);
}
}
}