Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#14008 closed defect (fixed)

images aren't exported correctly to SVG

Reported by: vvoovv Owned by: Eugene Lazutkin
Priority: high Milestone: 1.7
Component: DojoX GFX Version: 1.7.0b1
Keywords: Cc: Chris Mitchell
Blocked By: Blocking:


Correct SVG with images should look like:

<svg xmlns="" xmlns:xlink="" overflow="hidden">


<image xlink:href="http://someUrl" ... ></image>



Now open dojox/gfx/tests/test_utils.html

The exported SVG doesn't contain xmlns:xlink=""

Images are exported with href tag but not with xlink:href tag.

I would suggest to patch SVG string in the _cleanSvg function:

1) add xmlns:xlink=""

2) substitute href= for xlink:href=

Change History (6)

comment:1 Changed 8 years ago by Patrick Ruzand

Additional information: From my tests, this problem only appears on Chrome and Safari. FF and IE9 are ok.

Last edited 8 years ago by Patrick Ruzand (previous) (diff)

comment:2 Changed 8 years ago by Patrick Ruzand

Resolution: fixed
Status: newclosed

In [26708]:

fix #14008

comment:3 Changed 8 years ago by vvoovv

Resolution: fixed
Status: closedreopened

Your fix doesn't work for FF with gfxRenderer=canvas. In this case FF provides links with namespace xlink (xlink:href="someUrl"). But it doesn't provide xmlns:xlink definition.

The colon (:) is also considered as a border of a word for the \b regular expression. So we get xlink:xlink:href= after replacement.

My proposal is to substitute the line svg = svg.replace(/\bhref\s*=/g,"xlink:href="); with

if (svg.indexOf("xlink:href") == -1) svg = svg.replace(/href\s*=/g,"xlink:href=");

It would work than for Chrome&Safari, FF, Opera both for svg and canvas.

However there is general problem to export images under vml and silverlight. Export is performed without images. But export doesn't work at all with images

comment:4 Changed 8 years ago by Patrick Ruzand

Problem appears indeed with FF5+/canvas. update patch.

comment:5 Changed 8 years ago by Patrick Ruzand

Resolution: fixed
Status: reopenedclosed

In [26712]:

fix _cleanSvg for FF5/canvas configuration; fixes #14008

comment:6 Changed 8 years ago by Patrick Ruzand

In [26713]:

add more tests for xlink:href, refs #14008

Note: See TracTickets for help on using tickets.