Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9071

Re: Can't display .BMP graphics which is from smartforms in customer container

$
0
0

Hi Tao,

 

I'll try to guide you. The road is long but i hope that we will get it.

 

First of all we need get the HTML code. The Smartforms function it's returning this in binary mode.

 

DATA: lr_conv     TYPE REF TO cl_abap_conv_in_ce,

      wa_content  TYPE LINE OF tsfixml,

      lv_html_bin TYPE xstring,

      lv_html     TYPE string.

 

LOOP AT output_data-xmloutput-trfresult-content[] INTO wa_content.

  CONCATENATE lv_html_bin wa_content INTO lv_html_bin IN BYTE MODE.

ENDLOOP.

 

lr_conv = cl_abap_conv_in_ce=>create( input = lv_html_bin ).

lr_conv->read( IMPORTING data = lv_html ).

 

Now we need to seek the correct IMG tag. You should use CL_CRM_HTML_PARSER for this.

 

TYPE-POOLS cmail.

DATA lt_parts TYPE cmail_html_parser_tab.

 

cl_crm_html_parser=>parse_html_string(

  EXPORTING

    iv_html                = lv_html

    iv_all_tags_lower_case = abap_true

  IMPORTING

    et_parts               = lt_parts ).

 

LT_PARTS containts a structure which permits navigate into structure of HTML.

 

PART          => Complete tag in HTML syntax

TAG           => Tag type ( IMG , B , TR , TD , DIV... )

ATTRIBUTES    => Table with all attributes of tag

IS_END_TAG    => Indicates if it's a closing tag

REF_TAB_INDEX => Index tag

 

We need find IMG tags and checking inside attributes the correct ID to confirm which image is. Then you should change the src attribute and insert the image data in Base64 format.

 

Syntax examples of img:

 

Referenced image

<img id="(Image id) src="(url of file)" alt="(Alternative name)" />

 

Embeded image

<img id="(Image id) src="data:(mimetype);base64,(base64 data)" alt="(Alternative name)" />

<img id="MYGRAPH" src="data:image/bmp;base64,(base64data)" alt="Mygraph.bmp" />

 

For do the image conversion from binary to Base64 you can use SSFC_BASE64_ENCODE function module (Remember: You must do a CONCATENATE of table to collect into a string).

 

Now you can fill "src" attribute correctly with mimetype and Base64 data as in syntax example described above. To rebuild HTML code you should use CL_CRM_HTML_PARSER again.

 

cl_crm_html_parser=>concatenate_parts(

  EXPORTING

    it_parts  = lt_parts

  IMPORTING

    ev_string = lv_html ).

 

And... "Let there be HTML embeded image"!

 

I don't know if exist another simple way to do it, but I hope you find it useful.

Best regards,

Alex


Viewing all articles
Browse latest Browse all 9071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>