cancel
Showing results for 
Search instead for 
Did you mean: 

Rich Text in Adobe Interactive Forms (Bullets, Headings, etc...)

Former Member

Hello SAP Community,

I am attempting to dynamically append Rich Text to text fields in an Adobe Interactive Form. This includes, lists such as bullets and numbering, as well as headings.

I have attempted several different methods in making this occur, but I have had little success.

The closest method to success is to convert HTML to ExData using the Javascript code provided below.

HTML to ExData

//XML String to wrap the HTML

var envel = '<?xml version="1.0" encoding="UTF-8"?><exData contentType="text/html" xmlns="http://www.xfa.org/schema/xfa-template/2.8/"><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acroform:2.7.0.0" xfa:spec="2.1"><p>PLACEHOLDER</p></body></exData>';

//Current HTML Data

var htmldata = this.rawValue;

// insert into envelope

var newStr = envel.replace("PLACEHOLDER",htmldata);

//Load the final XML

this.value.exData.loadXML(newStr, 1, 1);

As a further note, Conversion must occur if exporting from an SAP WebDynPro.

  • The WebDynPro will export using the <strong></strong> tags instead of <b></b> for bold.
    • This can be fixed by using a `replace all occurrences of` statement.

Notes:

  • Each Text field's field format: 'Rich Text.'
  • The code provided above will allow the html bold tag (<b></b>) and italics tags (<i></i>) to work, but not the bullet code like (<ul><li></li></ul>)
  • It is possible to have a bullet visibly appear on the adobe form designer through modifying the XML Source, but it will not appear on the exported PDF.
  • The Adobe Document Server's Version Information: 802.20080813094752.488190

Any Help would be greatly appreciated, I will reply back with any information that may help.

Thanks,

Matt Fleming

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Mohammad and Juergen,

Thank you both for the information.

As Jeremey has stated, we are not on a version of the document server that will support the tags.

I am marking this question as assumed answered.

Thanks,

Matt Fleming

Former Member
0 Kudos

Hi Matt,

You'll need to use a more up to date version of ADS. It looks like you are using a 2008 ADS and support for li and ul was added at a later point in time (in 2011 I believe).

Best,

Juergen

Former Member
0 Kudos

Hi Juergen,

Can you give me an example of what version number would run the <ul>and <li> tags?

Thanks,

Matt Fleming

Former Member
0 Kudos

Hi Matt,

You'll need at least NW 7.31 and Designer 9.8. The ADS version number has a date in it (after the dot) like X.2011... it needs to be at least 2011 better 2012. I do not have access to a 7.31 system to check the exact version number.

Best,

Juergen

jer1
Explorer
0 Kudos

Thank you Juergen!  I am one of Matt's coworkers.

The version at our shop is x.2008, and we are on NW 7.01.  Looks like we are out of luck on the tags method...

Former Member
0 Kudos

Do all this in ABAP

1) Convert html to xstring

    data(lv_len) = strlen( lv_html ).

    data(lr_conv) = cl_abap_conv_out_ce=>create( ).

    lr_conv->write( data = lv_html n = lv_len ).

    lv_xstr = lr_conv->get_buffer( ).

2) XFA doesn't support most of the HTML tags so do the XSLT transformation

   call transformation zhtml_xslt

      source xml lv_xstr

      result xml lv_xstr.

3) Encode xstring to base64

   constants: lc_op_enc type x value 36.

   data: lv_base64 type string.

   call 'ssf_abap_service'

     id 'OPCODE' field lc_op_enc

     id 'BINDATA' field lv_xstr

     id 'B64DATA' field lv_base64.

4) Example XSLT     http://scn.sap.com/community/crm/webclient-ui-framework/blog/2014/01/14/converting-html-to-xhtml-usi...

        

                                   


Do all this is Adobe Form javascript

1) Create a global variable "Base64" and paste the script from below link
http://www.webtoolkit.info/javascript-base64.html

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

    var b64 = this.rawValue;

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

    this.value.exData.loadXML(xhtml);

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

Former Member
0 Kudos

Hi Mohammad,

I have tried manually inserting base64 encoded XHTML into the raw value of the form, all it does is decode the XHTML and put it there.

Input String: "<ul><li>a</li></ul>"

Base64 string: "PHVsPjxsaT5hPC9saT48L3VsPg=="

Decoded string: "<ul><li><div><em>a</em></div></li></ul>"

The base64 encoding and decoding works fine, but the adobe form is not taking it. It is also a little odd that <div> and <em> tags get added.

Former Member
0 Kudos

Hi Matt,

You might want to have a look at link below, there I have given the XSLT that does transformation for <ul> and <li> tags as well.

http://scn.sap.com/community/interactive-forms-by-adobe/blog/2016/03/31/render-htmlrich-text-in-adob...

Also give it a try with below input string

<body><p><b>this should be bold</b>this is not bold</p></body>

Former Member
0 Kudos

Hi Mohammad,

I have attempted to use the code provided in your tutorial but I recieve errors.

Most of them relate to data objects not being found. I have tried typing the variables as the class and executing them, which works, but the zhtml_xslt does not exist.

<b> and <i> tags work fine, but <h1-3>, <ul>, and <li> tags do not.

Message was edited by: Matt Fleming

Former Member
0 Kudos

Hi Matt,

That's because of your ABAP version which doesn't support inline declaration.

You might try as below, if you want


  DATA: lv_html TYPE string VALUE '<body><p><b>this should be bold</b>this is not bold</p></body>',
             lv_len  TYPE i,
             lr_conv TYPE REF TO cl_abap_conv_out_ce,
             lv_xstr TYPE xstring.


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

Create an XSLT transformation ZHTML_XSLT as in below link and copy paste the transformation from my blog.

http://help.sap.com/saphelp_nw73/helpdata/en/fd/9d734b389211d596a200a0c94260a5/frameset.htm