How to create a PDF file

Hello everyone!

Today we will learn how to create a PDF file with Salesforce!
Imagine for a minute that, after choosing Salesforce to better manage your business, HR asks you to be able to a candidate’s information as a PDF file.

Knowing it is not part of the standard functionality of Salesforce, how will you do?

We will proceed in two steps:
1) Creation of a Visualforce page
2) Creation of Static Resources

Below is your Applicant detail page

 

PDF3

 

And here is the PDF file you wish to have!

 

1) Creation of a Visualforce page

<apex:page standardController = ″Applicant__c″ renderAs = ″PDF″ >

<apex:image id=″popo″ value = ″{!$Resource.toto}″ width = ″100″ /><br/><br/>

<apex:stylesheet value = ″{!$Resource.logo}″/>

<apex:form >

<apex:pageBlock >

<!– Fields –>
<h2> Détails Applicant</h2>

<h1>PROFILE</h1>

<apex:pageBlockSection columns =″1″ >
{!Applicant__c.Profile__c} &nbsp;&nbsp; <br/><br/>
<b>Address:</b> {!Applicant__c.Address__c} &nbsp;&nbsp; <br/><br/>
<b>Phone:</b> {!Applicant__c.Phone__c} &nbsp;&nbsp;<br/><br/>

<b>Nom:</b> {!Applicant__c.Name} &nbsp;&nbsp; <br/><br/>

<b>Salary Requirements:</b> {!Applicant__c.Salary_Requirements__c} &nbsp;&nbsp; <br/>

<h1>PROFESSIONAL EXPERIENCE</h1>
<table>
<tr>
<th>Product Manager </th>
<th> Consultant </th>
</tr>
<tr>
<td>{!Applicant__c.second_experience__c }</td>

<td> {!Applicant__c.First_Experience__c }</td>
</tr>

</table>

</Apex:pageBlockSection>

<apex:pageBlockSection columns = ″1″ showHeader = ″true″ >
<h1>EDUCATION</h1>

<b> Previous Experience: </b> {!Applicant__c.Previous_Experience__c }<br/>
<b> Education: </b> {!Applicant__c.Education__c}&nbsp;&nbsp;<br/>
</apex:pageBlockSection>
<apex:pageBlockSection columns = ″4″ showHeader = ″true″ >
<h1>OTHER INFORMATION</h1>
<b>Languages:</b> {!Applicant__c.Languages__c} <br/>
<b>Interests:</b> {!Applicant__c.Interests__c}
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

2) Creation of Static Resources

For the beautiful look at your page PDF, create  static resources!

<style>
body { font-family: Arial Unicode MS;background-color:Aqua;}

h1 { color:Maroon;}
h2 {text-align: center; margin: 0; font-size: 1.5em; font-weight: normal;background-color:Maroon; color:white;}
</style>

After having done this, you will be able to generate a PDF file and add your Visualforce page to the Print button.