You need to sign in to do that
Don't have an account?
Viwal
Download as PDF button
Hi,
I have a inline visualforce page on an object detail page.
I want to have a Button on the object detail page which will dowload this page.
Anybody know how to do this?
Hi,
From the top of my head, you can create a Visualforce page which will with RenderAs=PDF attribute.
You page would be something like this:
<apex:page standardController="Account" showHeader="true" tabStyle="account" renderas="pdf" >
<apex:detail relatedList="true" title="true"/>
</apex:page>
You will then create a button that points to the visualforce page.
If the above didn't work for you, you could always code a boolean from a paramter and throw a If statement in the renderAs flag in the apex:page tag: renderAs="{!IF(printable,'pdf','')}"
and throw a simple commandlink (or button) like: <apex:commandLink value="View PDF" action="{!printPDF}"/>
Apex code:
Public Boolean printable {get; set;}
Public PageController()
{
printable = ((ApexPages.CurrentPage().getParameters().get('pdf') == 'true')?true:false);
}
public PageReference printPDF()
{
PageReference pdf = Page.YourPage;
for (String key : ApexPages.CurrentPage().getParameters().keySet())
{
//this will preserve your current parameters
pdf.getParameters().put(key, ApexPages.CurrentPage().getParameters().get(key));
}
pdf.getParameters().put('pdf','true');
pdf.setRedirect(true);
return pdf;
}