How to convert a web page into PDF format using renderAs attribute

Companies frequently need web page data to be converted into PDF. So, they can have an easy look into the progress. For this in salesforce, we can convert visualforce pages, which consist of critical data into PDF format.

In salesforce, many customized pages and data are developed according to the requirement. Those customized pages and data are done within visualforce pages, hence these pages can be converted into PDF file.

Visualforce pages can be converted into PDF by using "renderAs" attribute.

By adding the "renderAs" attribute to the <apex:page> component like for example:


<apex:page standardController="Contact" renderAs="pdf" >

Visualforce page creation:

We have to create Visualforce page, which is to be converted into PDF format, below is the code which generates Visualforce page:


<apex:page standardController="Contact" >

<apex:form >

<h1 style="font-size:25px;">Converting to pdf format</h1>

<body>

<table style="width:100%">

<tbody style="diasplay:table-row-group;vertical-align:middle;">

<tr style="display:table-row;">

<th style="font-size:1 em;text-align:left;padding-top:6px;padding-bottom:5px;padding:2px 6px 3px 7px;line-height:50px;"> Company name </th>

<th> Contact number </th>

</tr>

<tr>

<th> Micropyramid inf pvt ltd </th>

<th> 04065996999 </th>

</tr>

</tbody>

</table>

2. Add renderAs="pdf" attribute to the apex component to convert into pdf page

<apex:page standardController="Contact" renderAs="pdf" >

 

    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Need any Help in your Project?Let's Talk

Latest Comments
Related Articles
How to enable opportunity splits in salesforce Raja Gulla

Opportunity splits allows sales representatives to divide credit and revenue on any sales deal. If your sales process splits revenue from closed-won deals to give ...

Continue Reading...
How to run a SOQL query in Salesforce Vinisha Naladala

Salesforce Object Query Language(SOQL) is used to fetch the data from Sobject in salesforce organization. As we know SQL is used by .Net developers to ...

Continue Reading...
Field Update Workflow in Salesforce Raja Gulla

In Salesforce, field update is used to change or update field records. This can be done by a creating field update actions and associating them ...

Continue Reading...
open source packages

Subscribe To our news letter

Subscribe and Stay Updated about our Webinars, news and articles on Django, Python, Machine Learning, Amazon Web Services, DevOps, Salesforce, ReactJS, AngularJS, React Native.
* We don't provide your email contact details to any third parties