on 03-29-2016 3:47 PM
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.
Notes:
Any Help would be greatly appreciated, I will reply back with any information that may help.
Thanks,
Matt Fleming
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
Also give it a try with below input string
<body><p><b>this should be bold</b>this is not bold</p></body>
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
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.