Thursday, May 23, 2013

BI Publisher HTML to PDF from ADF Rich Text Editor (RTE) line breaks and paragraphs


I’m using ADF rich text editor that saves formatted HTML in a database field (CLOB). Then using BI Publisher for generate a report with RTF template that includes that formatted text. The result gives me a bad formatting for line breaks (<br/> tags) and paragraph (<p> tags) for PDF report format.

My field data is as follows: <p>...<br/>...<br/>...</p>

A solution that works for me is the following:
·         - set the data type for field on report model as XML

·         - on the SQL use this for your RTE field
'<![CDATA' || '['|| replace(replace(RTE_FIELD_NAME,'<br/>', '<fo:block linefeed-treatment="preserve"></fo:block>'),'<p>','<xsl:text>&nbsp;

</xsl:text>') || ']' || ']>'

·         - On RTF template use this on the field on the advanced tab:
<?html2fo:RTE_FIELD_NAME?>

If you have multiple <p> tags you can replace them first with double <br/> 's and replace after the <br/> with:
<fo:block linefeed-treatment="preserve">
</fo:block>

3 comments:

  1. Thanks Christos. This post really helped us out today.

    ReplyDelete
  2. its not working for me : Namespaceprefix 'html2fo' used but not declared

    ReplyDelete
  3. div tag is not displaying properly. Can you please tell me how to handle this situation?

    ReplyDelete

Note: Only a member of this blog may post a comment.