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
Elanie CathennaElanie Cathenna 

How to render vf page as pdf?

Hi please take it as a priority because I am new in vf page learning and the client has required a pdf of the render vf page.

 
Best Answer chosen by Elanie Cathenna
Suraj Tripathi 47Suraj Tripathi 47

Hi,
You can take references from the below link.

<apex:page standardController="Account" extensions="AccountPDFController" renderAs="pdf" applyBodyTag="false">
 <head>
 <style type="text/css">
 body { font-family: Arial Unicode MS; }
 </style>
 </head>
 <h1>Account Information</h1>
 <apex:panelGrid columns="2" border="1" cellspacing="0" cellPadding="5" width="100%">
 <apex:outputText value="{!$ObjectType.Account.fields.Name.label}" />
 <apex:outputText value="{!Account.Name}" />
 <apex:outputText value="{!$ObjectType.Account.fields.AccountNumber.label}" />
 <apex:outputText value="{!Account.AccountNumber}" />
 <apex:outputText value="{!$ObjectType.Account.fields.WebSite.label}" />
 <apex:outputText value="{!Account.WebSite}" />
 <apex:outputText value="…" />
 <apex:outputText value="…" />
 </apex:panelGrid>
</apex:page>
 
public class AccountPDFController {
public AccountPDFController(ApexPages.StandardController controller) {
Account acc = (Account)controller.getRecord();
String accNum = acc.AccountNumber;
//Assign "Account_[Ac].pdf" as a file name
String fileName = 'Account_' + accNum + '.pdf';
Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=' + fileName);}}

Please visit this link: https://www.terrasky.com/post/create-a-render-a-visualforce-page-as-pdf-button

https://developer.salesforce.com/forums/?id=906F0000000Ai0XIAS

https://developer.salesforce.com/forums/?id=906F0000000Ai0XIAS

Please mark it as the Best Answer so that other people would take references from it.

Thank ou

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi Elanie,

try with this, renderAs="pdf"
<apex:page standardController="Account" renderAs="pdf">

If this helps, please mark it as best answer.

Thanks,
Ankaiah
 
Suraj Tripathi 47Suraj Tripathi 47

Hi,

You can take references from the below link.

<apex:page standardController="Account" extensions="AccountPDFController" renderAs="pdf" applyBodyTag="false">
 <head>
 <style type="text/css">
 body { font-family: Arial Unicode MS; }
 </style>
 </head>
 <h1>Account Information</h1>
 <apex:panelGrid columns="2" border="1" cellspacing="0" cellPadding="5" width="100%">
 <apex:outputText value="{!$ObjectType.Account.fields.Name.label}" />
 <apex:outputText value="{!Account.Name}" />
 <apex:outputText value="{!$ObjectType.Account.fields.AccountNumber.label}" />
 <apex:outputText value="{!Account.AccountNumber}" />
 <apex:outputText value="{!$ObjectType.Account.fields.WebSite.label}" />
 <apex:outputText value="{!Account.WebSite}" />
 <apex:outputText value="…" />
 <apex:outputText value="…" />
 </apex:panelGrid>
</apex:page>
 
public class AccountPDFController {
public AccountPDFController(ApexPages.StandardController controller) {
Account acc = (Account)controller.getRecord();
String accNum = acc.AccountNumber;
//Assign "Account_[Ac].pdf" as a file name
String fileName = 'Account_' + accNum + '.pdf';
Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=' + fileName);}}


Please visit this link: https://www.terrasky.com/post/create-a-render-a-visualforce-page-as-pdf-button

Thank You

Suraj Tripathi 47Suraj Tripathi 47

Hi,
You can take references from the below link.

<apex:page standardController="Account" extensions="AccountPDFController" renderAs="pdf" applyBodyTag="false">
 <head>
 <style type="text/css">
 body { font-family: Arial Unicode MS; }
 </style>
 </head>
 <h1>Account Information</h1>
 <apex:panelGrid columns="2" border="1" cellspacing="0" cellPadding="5" width="100%">
 <apex:outputText value="{!$ObjectType.Account.fields.Name.label}" />
 <apex:outputText value="{!Account.Name}" />
 <apex:outputText value="{!$ObjectType.Account.fields.AccountNumber.label}" />
 <apex:outputText value="{!Account.AccountNumber}" />
 <apex:outputText value="{!$ObjectType.Account.fields.WebSite.label}" />
 <apex:outputText value="{!Account.WebSite}" />
 <apex:outputText value="…" />
 <apex:outputText value="…" />
 </apex:panelGrid>
</apex:page>
 
public class AccountPDFController {
public AccountPDFController(ApexPages.StandardController controller) {
Account acc = (Account)controller.getRecord();
String accNum = acc.AccountNumber;
//Assign "Account_[Ac].pdf" as a file name
String fileName = 'Account_' + accNum + '.pdf';
Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=' + fileName);}}

Please visit this link: https://www.terrasky.com/post/create-a-render-a-visualforce-page-as-pdf-button

https://developer.salesforce.com/forums/?id=906F0000000Ai0XIAS

https://developer.salesforce.com/forums/?id=906F0000000Ai0XIAS

Please mark it as the Best Answer so that other people would take references from it.

Thank ou

This was selected as the best answer
Mukesh Kumar 470Mukesh Kumar 470
 create a LWC component to show EmailStatus.

There is an object named as email status show that in LWC.