Skip to Content
0
Apr 25, 2014 at 11:36 AM

CL_GUI_HTML_VIEWER: Mix SVG and HTML content

715 Views

Hi there,

I would like to create a small example to mix some html content (e.g. an table) with a dynamically created svg file. If I test a SVG only, this works and is shown correctly, but as soon as I try to include the SVG as an <object> it fails.

So I create the SVG this way:

* Create SVG File

APPEND '<?xml version="1.0" encoding="UTF-8"?>' TO gt_svg.

APPEND '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="700px" height="400px" viewBox="0 0 700 400">' TO gt_svg.

APPEND '<line x1="0" y1="200" x2="700" y2="200" stroke="black" stroke-width="20px"/>' TO gt_svg.

APPEND '<rect x="100" y="100" width="500" height="200" fill="white" stroke="black" stroke-width="20px"/>' TO gt_svg.

APPEND '<line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/>' TO gt_svg.

APPEND '<polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/>' TO gt_svg.

APPEND '</svg>' TO gt_svg.

* Prepare url

gv_svgurl = 'small.svg'.

* Load SVG Data

CALL METHOD gr_browser->load_data

EXPORTING

url = gv_svgurl

type = 'text'

subtype = 'svg'

IMPORTING

assigned_url = gv_svgurl

CHANGING

data_table = gt_svg[]

EXCEPTIONS

OTHERS = 4.

If I load this url directly the SVG is shown correctly:

*** Show Url

CALL METHOD gr_browser->show_url

EXPORTING

url = gv_svgurl.

Great, but now I would like to link the created SVG (GV_SVGURL) into an html file. I tried this as <OBJECT> <IFRAME> and <IMG>:

DATA: lv_helper TYPE string.

append '<html>...some html content...' to gt_html.

CONCATENATE '<object id="svg1" type="image/svg+xml" data="' gv_svgurl '"></object>' INTO lv_helper. append lv_helper to gt_html. CONCATENATE '<iframe src="' gv_svgurl '"></iframe>' INTO lv_helper. append lv_helper to gt_html. CONCATENATE '<img src="' gv_svgurl '">' INTO lv_helper. append lv_helper to gt_html.

*** Close HTML

append '</body></html>' to gt_html.

Additionally to the load_data for the SVG, I load the html content:

gv_url = 'test.htm'.

* Load HTML Data

CALL METHOD gr_browser->load_data

EXPORTING

url = gv_url

IMPORTING

assigned_url = gv_url

CHANGING

data_table = gt_html[].

*** Show Url

CALL METHOD gr_browser->show_url

EXPORTING

url = gv_url.

This will not work. The HTML content is shown, the <OBJECT> is empty, the <IMG> shows an 'X' icon (not found?). The most successfull is the IFRAME. It shows the content of the SVG, but as source code - not the image. But this way I can be sure that the viewer can load the SVG.

Attachments

svg.png (84.8 kB)