I have a requirment to create a custom document where the font colors change depending on the value of the field. My first thought was Conga but working with the if statement is Word is a pain. I thought it would be easier to write a visualforce page that renders as a PDF.

Below is the basic code. The color rendering works fine as a web page but as soon as I add renderAs="PDF" I loose the font colors. Is there a way to make this work?

<apex:page id="Region_Health_Check" showHeader="false" standardController="Region__c" docType="html-5.0"
           sideBar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" renderAs="pdf">
        <title>Region Health Check Report</title>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <apex:stylesheet value="{!$Resource.HealthCheckStyle}"/>
    <table width="100%">
        <tr width="100%">
            <td width="50%" align="left">Email Engagement Score Card</td>
            <td width="50%" align="right">Overall Health Check Score</td>
        <tr width ="100%">
            <td width="50%">
                <span style="font-family: BrownStd; font-size: 24px">
                     <apex:outputText value="{!Region__c.Name}"/>
            <td  width="50%" align="center">
                <font color="{!if(Region__c.Grade__c='A', 'green', 'blue')}">
                    <apex:outputText value="{!Region__c.Grade__c}" style="font-size: 39px; font-family: BrownStd, SansSerif"/>
  • 2
    Instead of renderAs=pdf" can you try renderAs="advanced_pdf" ? src: releasenotes.docs.salesforce.com/en-us/summer17/release-notes/… Nov 29, 2018 at 13:49
  • I tried advanced_pdf and the font colors still did not work.. Nov 29, 2018 at 14:12
  • @PranayJaiswal i have one question, what if i render the data through the javascript remote method invocation, and then i want print pdf on any event. and how can i get advanced_pdf feature to my org.
    – Umesh Beti
    May 24, 2019 at 11:40

1 Answer 1


Try putting the color parameter inside the style of the outputText.

<apex:outputText value="{!Region__c.Grade__c}"
                 style="color:{!if(Region__c.Grade__c='A', 'green', 'blue')}; 
                        font-size: 39px;
                        font-family: BrownStd, SansSerif"

I think this should work


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .