Rendering HTML/Rich Text in Adobe Form is one of the common requirements people often have.

So here is the step by step process to achieve it. 

Do this in ABAP
1) Convert html to xstring – lv_html is your html string

DATA: lv_html TYPE string.
DATA(lv_len) = strlen( lv_html ).
DATA(lr_conv) = cl_abap_conv_out_ce=>create( ).
lr_conv->write( data = lv_html n = lv_len ).
DATA(lv_xstr) = lr_conv->get_buffer( ).

2) XFA doesn’t support most of the HTML tags so do the XSLT transformation for the tags you need

          SOURCE XML lv_xstr
          RESULT XML lv_xstr.
   CATCH cx_transformation_error INTO DATA(lr_transformation_error).

3) Encode xstring to base64

CONSTANTS: lc_op_enc TYPE x VALUE 36.
DATA: lv_base64 TYPE string.
      ID ‘OPCODE’ FIELD lc_op_enc
      ID ‘BINDATA’ FIELD lv_xstr
      ID ‘B64DATA’ FIELD lv_base64.

4) Example XSLT

<xsl:transform xmlns:xsl="" xmlns:sap="" version="1.0">
  <xsl:output encoding="UTF-8" indent="yes" method="xhtml" standalone="0" version="1.0"/>
  <xsl:strip-space elements="*"/>
  <xsl:variable name="vDelims" select="'- • # '"/>
  <xsl:template match="@*|node()">
      <xsl:apply-templates select="@*|node()"/>
  <xsl:template match="/">
  <xsl:template match="h2">
      <xsl:apply-templates select="@*|node()"/>
  <xsl:template match="ul">
    <p style="text-decoration:none;letter-spacing:0in">
      <xsl:apply-templates select="@*|node()"/>
  <xsl:template match="p">
      <xsl:apply-templates select="@*|node()"/>
  <xsl:template match="li">
    <span style="xfa-tab-count:1">         </span>
    <xsl:for-each select="ancestor::ul">
      <xsl:text>  </xsl:text>
    <xsl:value-of select="substring($vDelims,
              2*(1+count(ancestor::ul) mod 3) -1,
    <xsl:value-of select="."/>

Do this in Adobe Form field’s javascript

1) Create a global variable “Base64” and paste the script from below link

2) Write below code in the field’s javascript to decode base64

var b64 = this.rawValue;
var xhtml = base64.Base64.decode(b64);

3) Make sure the script is set to Run At Server, if it’s an interactive form

4) Make sure the field is rich text enabled



To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Raghavendra Prabhu Mithal

    Very innovative and good job. Thanks for sharing, this is really helpful, it would have been good if u had an image of the output also, and bit explanation on XSLT as to what tags are not compatible and replaced with what.




Leave a Reply