Blog.

How to create a PDF page

By Published On: November 6th, 2020Categories: Features Marketing Cloud|Uncategorized

The discovery

Your HR department is using Salesforce to manage applicant data below is the screenshot of the applicant details. A recruiter needs to extract an applicant’s profile as a well-formatted PDF for internal review. Out of the box, Salesforce doesn’t offer a built-in export-to-PDF function for custom objects. What now?

PDF3

The challenge with the current process

You can’t just click a button and download a PDF with structured data and branding. You need a way to programmatically create a printable version of a record that reflects your organisation’s style, layout, and fields, all without introducing external tools.

“How do you generate a clean, styled PDF file from an Applicant record directly within Salesforce?”

Show me and implementation

 

Use a Visualforce page with the renderAs="pdf" attribute and a custom static resource to style the layout. This lets you build a fully branded, printable document—right from your Salesforce org.

Create the Visualforce Page

Here’s a Visualforce page that renders the details of the Applicant__c object as a PDF:

<apex:page standardController="Applicant__c" renderAs="pdf">
    <apex:stylesheet value="{!$Resource.ApplicantStyles}" />

    <apex:form>
        <apex:pageBlock title="Applicant Details">
            
            <h2>Profile</h2>
            <p><strong>Name:</strong> {!Applicant__c.Name}</p>
            <p><strong>Profile:</strong> {!Applicant__c.Profile__c}</p>
            <p><strong>Address:</strong> {!Applicant__c.Address__c}</p>
            <p><strong>Phone:</strong> {!Applicant__c.Phone__c}</p>
            <p><strong>Salary Requirements:</strong> {!Applicant__c.Salary_Requirements__c}</p>

            <h2>Professional Experience</h2>
            <table border="1" cellpadding="5" cellspacing="0" width="100%">
                <tr>
                    <th>First Experience</th>
                    <th>Second Experience</th>
                </tr>
                <tr>
                    <td>{!Applicant__c.First_Experience__c}</td>
                    <td>{!Applicant__c.Second_Experience__c}</td>
                </tr>
            </table>

            <h2>Education</h2>
            <p><strong>Education:</strong> {!Applicant__c.Education__c}</p>
            <p><strong>Previous Experience:</strong> {!Applicant__c.Previous_Experience__c}</p>

            <h2>Other Information</h2>
            <p><strong>Languages:</strong> {!Applicant__c.Languages__c}</p>
            <p><strong>Interests:</strong> {!Applicant__c.Interests__c}</p>

        </apex:pageBlock>
    </apex:form>
</apex:page>

Tip: Ensure the Applicant__c custom object exists, and upload any necessary images (like logos) as static resources.

Add Styling with a Static Resource

Upload a CSS file as a static resource named ApplicantStyles. Here’s a sample:

/* File: ApplicantStyles.css */
body {
    font-family: Arial, sans-serif;
    background-color: #F5F5F5;
    color: #333;
    margin: 20px;
}

h2 {
    background-color: maroon;
    color: white;
    padding: 10px;
    font-size: 1.2em;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid #666;
    padding: 8px;
    text-align: left;
}

Uploading Your Static Resource:

  1. Go to SetupStatic Resources

  2. Click New

  3. Name it ApplicantStyles

  4. Upload the .css file and set cache control to Public

 Add a Custom Button (Optional but Recommended)

Enable users to generate the PDF from the record page:

  1. Go to Object ManagerApplicant__cButtons, Links, and Actions

  2. Create a new button (e.g., “Download PDF”)

  3. Set the behavior to Display in new window

  4. Use the URL format:

    /apex/YourVisualforcePageName?id={!Applicant__c.Id}
  5. Add the button to the page layout

Value and business outcome

You’ve now empowered your HR team to click one button and generate a styled PDF of any applicant’s details. This boosts efficiency, consistency, and professionalism—without needing any third-party tool.

 

Share This Story, Choose Your Platform!

Leave A Comment