jeff.pace

Possible bug in dojox.gfx.utils.toSvg (JSAPI 2.7 and older)

Discussion created by jeff.pace on Mar 12, 2012
I think i found a bug in the ESRI implementation of dojox.gfx.utils.toSvg

To get around a number of printing issues, we modified the map2pdf code to build our own print engine.  To support graphics, I manually take the Graphics layer and convert it to SVG in text form and then render it on the server side in Java.

However

if you do (modified code below)

if (layer instanceof esri.layers.GraphicsLayer) {
var graphics = layer.graphics;
var d = graphics[0].getDojoShape();
var de = d.getParent();
var def=  dojox.gfx.utils.toSvg(de);  //i think this is where the problem is
def.addCallback(dojo.hitch(this, function(graphic) {
alert(""+graphic);
}


THe alert is different depending on the browser.  It works in Safari, IE8+, and Firefox.  However in Chrome (including 18dev build) and IE7 and below, there are two typos in the svg text

1. It starts with <svg instead of <g  (the end tag is /g>)
2. it has d= instead of id= and the space is missing

This results in invalid character errors dealing with the svg text.

Not sure if this is a dojo bug or and ESRI bug implementing it.

Right now i just trap for the browser type and do a string replacement, but that is very hacky.

Outcomes