1

I am building a Visualforce page as PDF and i want to show some sections and clauses of a Contract, which are within Salesforce as records. The value i want to display is rich text area and this rich text area has some words in bold. However, this styling is not applied. Has anyone faced this issue in the past or has an idea on how to handle this? Code below. Field that is not displayed with the appropriate styling: csclm__Final_Rich_Text__c

<div class="section">
                    <apex:repeat value="{!sections}" var="section">
                        <div class="section section{!section.csclm__Level__c}">
                            <p
                               class="subsection{!section.csclm__Level__c}" style="font-family: Arial Unicode MS;">
                                {!section.csclm__Numbering__c}
                                {!section.csclm__Section_Name__c}</p>
                            <apex:repeat value="{!section.csclm__Transactional_Clauses__r}"
                                         var="clause">
                                <div class="clause clause{!clause.csclm__Level__c}" style="font-family: Arial Unicode MS;">
                                    <span class="numbering">{!clause.csclm__Numbering__c}</span>
                                    <apex:outputText value = "{!clause.csclm__Final_Rich_Text__c}" escape="false" richtext="true"></apex:outputText>
                                </div>
                            </apex:repeat>
                        </div>
                    </apex:repeat>
                </div>

Example of record in Salesforce (Rich Text Area), word test is in bold!: enter image description here

Example of how it is rendered in PDF through VF page. As you can see, there is no difference between the text "TEST", which should be in bold and the rest of the sentence.

enter image description here

4
  • 1
    Can you try apex:outputField Dec 24, 2020 at 10:42
  • Thanks for your response Nagendra. By using apex:outputField i see that bold letters do work. However, i have problem with showing special characters (e.g. Greek letters). Do you have a suggestion on this? Dec 24, 2020 at 11:04
  • Can you share an example? I just used it and was able to show that β Dec 24, 2020 at 11:04
  • Try this please: "O Προμηθευτής, είναι κάτοχος νόμιμης Άδειας Προμήθειας και Άδειας Παραγωγής Ηλεκτρισμού, και αναλαμβάνει να προμηθεύει ηλεκτρική ενέργεια στο σημείο σύνδεσης του Πελάτη" Dec 24, 2020 at 11:10

2 Answers 2

2

I was going through the documentation and I believe this is a limitation from salesforce end.

Documentation

The PDF rendering service renders the markup and data on your page, but it might not render formatting contained within the contents of rich text area fields added to the page.

But try adding this:

<head>
    <style>
        body { font-family: 'Arial Unicode MS'; }
    </style>
</head>

and it displays greek letters too.


<apex:page showHeader="false" applyBodyTag="false" renderAs="pdf" controller="test54">
    <head>
        <style>
            body { font-family: 'Arial Unicode MS'; }
        </style>
    </head>
    <body>
    <apex:pageBlock>
        <apex:pageBlockSection title="Opportunity Information">
            <apex:outputField value="{!listOpportunity.name}"/>
            <apex:outputField value="{!listOpportunity.TestRichText__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </body>
</apex:page>

enter image description here

1
  • Nagendra, thank you very much for your detailed response. However, i still cannot achieve bold letters (formatting) and greek letters. :( If you find something, let me know:) However, i would like to thank you for your time and wish you merry Christmas!!! Dec 24, 2020 at 16:22
0

I have had this problem. This is the line I used to fix it.

<apex:outputText escape="false" style="font-weight:normal; white-space:pre; padding-bottom:5px" value="{!SUBSTITUTE(Quote.Notes__c,'</p>', '<br>')}" rendered="{!IF(OR(ISBLANK(Quote.Notes__c),Quote.Notes__c="<div><br></div>"),false,true)}"/>

Outputtext on a Rich Text Field would render the HTML of the field on the PDF.

<p>Test</p><p>Test</p><p>Test</p>

As you can see it doesn't show <br> or </br>. I used the Substitute function to replace the </p> with <br>. This worked perfectly for me.

1
  • Hello Andrew, did this solved you issue with non-latin characters - bold? Unfortunately, still the greek letters are not shown in bold in visualforce. Sep 1, 2022 at 14:49

You must log in to answer this question.

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