Is there an equivalent of canvas's toDataURL method for SVG?
var dataUrl = 'data:image/svg+xml,'+encodeURIComponent(svgString);
From: http://www.svgopen.org/2009/papers/12-Using_Canvas_in_SVG/#d4e105
The reason why you cannot use an SVG image element as source for the drawImage method is simple, but painful: the current Canvas specification does not (yet) allow to reference SVGImageElement as source for drawImage and can only cope with HTMLImageElement, HTMLCanvasElement and HTMLVideoelement. This short-coming will hopefully be addressed during the process of defining "SVG in HTML5" behavior and could be extended to allow SVGSVGElement as well. The xhtml:img element in listing 3 uses visibility:hidden as we do not want it to interfere with its visible copy on the Canvas.