You can do this .Please write a apex class to read the content of your email template.Then parse the merge fields and replace them with the values .Build a apex page and save it as pdf .Call this from a link or button .This can be the solution for this .
Thanks Rakesh. I tried that, but somehow when i am rendering the vf page as pdf, and outputing the HTMLValue of the email template, its just showing html code, but not rendering as html web page.
you are doing it in correct way ... try putting the html value in the string and access that string .do you have any merge fields in your template ?? if yes then you need to write a parser for that which parse your full template ....and generate code for pdf .!! Let me know soon !!!
Controller public class Test_Sid{ public String pdfContent {get;set;} public Test_Sid(){ pdfContent = [Select id,Body,Subject,DeveloperName,HtmlValue from EmailTemplate where id = '00X23000000QAnY'].HTMLValue; } }
You can do this .Please write a apex class to read the content of your email template.Then parse the merge fields and replace them with the values .Build a apex page and save it as pdf .Call this from a link or button .This can be the solution for this .
Hope solution helps !!
Regards,
Rakesh
HTMLValue of the email template, its just showing html code, but not rendering as html web page.
Page
<apex:page controller="Test" renderAs="pdf">
<apex:outputText value="{!testTemplate.HTMLValue}" escape="false"/>
</apex:page>
Controller
testTemplate = [Select id,Body,Subject,DeveloperName,HtmlValue from EmailTemplate where DeveloperName = :templateName];
Anything i am missing ?
<apex:outputText value="{!pdfContent}" escape="false"/>
</apex:page>
Controller
public class Test_Sid{
public String pdfContent {get;set;}
public Test_Sid(){
pdfContent = [Select id,Body,Subject,DeveloperName,HtmlValue from EmailTemplate where id = '00X23000000QAnY'].HTMLValue;
}
}
Page
<apex:page controller="Test_Sid" renderAs="pdf" cache="false" showHeader="false" sidebar="false" showChat="false">
<apex:outputText value="{!pdfContent}" escape="false"/>
</apex:page>