function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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;
    }

}