• Post category:BI Publisher
  • Post comments:0 Comments
  • Post last modified:June 6, 2021
  • Reading time:3 mins read
You are currently viewing How to display HTML formatted text using HTML2FO function and RTF template?
How to display HTML formatted text using HTML2FO function and RTF template
- How to display HTML formatted text using HTML2FO function and RTF template?
Total Visits: 9

In this article, we will look into how to use display the CLOB text on the output using the RTF template.

If we have the HTML code filled into the CLOB field on the application, it will convert and show the html formatted text on the application but in the backend it will still store as the html formatted text. So when you create a report to pull that field, what we get is the text with html functions. However, it will not be of much help to the end-users running the report as they cannot see what they can find on the application.

In order to handle this case, we have a function called HTML2FO which converts the HTML text into the HTML formatted text output.

<?html2fo: elementname?>

Where elementname is the tag on the XML file which contains the HTML data.

Let’s check the sample:

<?xml version="1.0" encoding="UTF-8"?>
<HTMLCODE>
<![CDATA[
<p><a href="http://www.fusionhcmknowledgebase.com">Fusion HCM Knowledgebase</a></p>
<p><a href="https://fusionhcmknowledgebase.com/vip-membership-plans/">Check out VIP Membership Plans for exclusive content</a></p>
]]>
</HTMLCODE>

Below is the RTF template with HTML2FO used.

image 12 - How to display HTML formatted text using HTML2FO function and RTF template?

The output will look like below:

image 13 - How to display HTML formatted text using HTML2FO function and RTF template?

If you can see, the HTML2FO doesn’t take into consideration the BI default font, so the first paragraph and the HTML2FO paragraphs look different.

In order to format the HTML2FO text to the same formatting as similar to other paragraphs, we need to apply explicit formatting to the HTML2FO function.

The formatting can be applied by creating a template function in the RTF template.

Code for creating a template. We have used the tag HTMLCODE which consists of the HTML text on the XML file.

<xsl:template name="HTMLTEXT">
<fo:inline padding-bottom="0.0pt" text-align="start" padding-top="0.0pt" end-indent="0.0pt" linefeed-treatment="preserve" start-indent="0.0pt" height="0pt" font-family="Calibri" font-size="12px">
<xsl:value-of select="xdoxslt:HTML2FO($_XDOXSLTCTX, (.//HTMLCODE)[1], '')" disable-output-escaping="yes"/>
</fo:inline>
</xsl:template>

We need to insert a field from the XML file and copy paste this template to that field. After that we can call the template in the RTF template to show the html formatted text.

Sample RTF template with all of this logic implemented:

image 14 - How to display HTML formatted text using HTML2FO function and RTF template?

The output will look like below:

image 15 - How to display HTML formatted text using HTML2FO function and RTF template?

Now, the paragraph and the HTML formatted text are using the same font and properties.

Download Sample Files:

Please subscribe to VIP Membership Plans to see the Download Links
Content visible only for non-members

Hope this was a good read.

If you like the content, please follow us on LinkedInFacebook, and Twitter to get updated with the latest content.