Rich Text Field Formatting Considerations
Clean up extra spacing from rich text fields and control paragraph tags in merge fields and related lists.
Rich text fields often create extra spacing in generated documents.
Problem
Salesforce rich text values usually contain HTML such as <p> and <br>.
That can cause a few common issues:
Extra blank lines between paragraphs
Missing bold or italic styles when Unicode fonts are fully enabled
Font substitution in PDF output, such as Times New Roman
Solution 1: Clean up a merge field
Use this pattern when you output a single rich text field directly in the template.
<div style="font-family: sans-serif;">{{{!Object.fieldname replaceall="#LT#/p#GT##LT#
p#GT##LT#br#GT#,#LT#br#GT#,#LT#/p#GT##LT#p#GT#,#LT#br#GT#,#LT#p#GT#, ,#LT#/p#GT#, "}}}</div>This replaces paragraph tags with single break tags and removes extra spacing.
Example
Field value stored in Salesforce
<p>First line</p><p><br></p><p>Second line</p>Rendered output
Solution 2: Remove all paragraph tags in a related list
Use this option when a related list column should render as plain text with line breaks only.
Example
Field value stored in Salesforce
Rendered output
Solution 3: Keep the first and last paragraph tags in a related list
Use this option when you want to preserve the outer paragraph wrapper and still remove the extra blank line in the middle.
Example
Field value stored in Salesforce
Rendered output
Tag reference
Use encoded tokens inside merge fields.
Use literal HTML tags inside related list column attributes.
#LT#p#GT#
<p>
#LT#/p#GT#
</p>
#LT#br#GT#
<br>
#QUOT#
"
#AMP#
&
Last updated
Was this helpful?

