Render a Visualforce Page as a PDF File

Render a Visualforce Page as a PDF File

When you render a Visualforce page as a PDF file, it can either be displayed in the browser or downloaded depending on the user's settings. The behavior may vary based on the browser, its version, and user preferences, which is beyond Visualforce's control. You can use the PDF rendering service to generate a printable PDF of a Visualforce page.

Example -

Visualforce Page

<apex:page standardController="Contact" renderAs="pdf"> <h1>Contact Details - Hi {!Contact.Name}</h1> <p>Your account details are:</p> <table> <tr><th>Account Name</th> <td><apex:outputText value="{!Contact.Account.Name}"/></td> </tr> <tr><th>Customer Since</th> <td><apex:outputText value="{0,date,long}"> <apex:param value="{!Contact.CreatedDate}"/> </apex:outputText></td> </tr> </table> </apex:page>

A Visualforce Page Rendered as a PDF File






























Comments

Popular posts from this blog

Introduction to Salesforce Agent Script: Build Predictable AI Agents

Anti-Patterns in Salesforce Agentforce: What to Avoid When Building AI Agents

MCP vs. Traditional APIs: Choosing the Right Integration Approach