+ Start a Discussion

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) 

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"/>


public class DynamicPdf {
    String pageFormat;

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

    public String getPageFormat() {
        return pageFormat;