+ Start a Discussion
TejTej 

Render as Pdf on Save

I have a req, where the user fills out a form and on save it should be rendered as PDF,

 

Can anyone please help me out.

 

Best Answer chosen by Admin (Salesforce Developers) 
TheSwamiTheSwami

Try this page and controller:

 

<apex:page controller="DynamicPdf" renderAs="{!pageFormat}" standardStylesheets="false">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus sollicitudin justo, nec tempus turpis ullamcorper eget. Proin vel nisl in justo rhoncus vehicula.
  <apex:form >
      <apex:commandButton action="{!go}" value="Go"/>
  </apex:form>
</apex:page>

 

public class DynamicPdf {
    String pageFormat;

    public PageReference go() {
        pageFormat = 'pdf';
        return Page.DynamicPdf;
    }


    public String getPageFormat() {
        return pageFormat;
    }

}