1

I am using HTML 5 svg tag to render some graphical objects. What I need is a way to export the drawn graphics into a file. I know that the good old "canvas" tag can do that as simple as:

var img = myCanvas.toDataURL("image/png");

So my question is simple - Can I do something similar with the svg tag or is there any way to convert the svg to canvas so that i can export the canvas?

Thanks!

PS: I have many reasons and constraints to use svg tag over canvas, so changing my implementation is not an option here.

Milen Igrachev
  • 259
  • 7
  • 17
  • 1
    http://fabricjs.com/ might do the trick for you. – Darlesson Nov 23 '16 at 17:18
  • 1
    Possible duplicate of [Convert SVG to image (JPEG, PNG, etc.) in the browser](http://stackoverflow.com/questions/3975499/convert-svg-to-image-jpeg-png-etc-in-the-browser) – Turnip Nov 23 '16 at 17:20
  • just draw the svg into the canvas and then get the image from the canvas. http://stackoverflow.com/questions/3768565/drawing-a-svg-file-on-a-html5-canvas – Sebastián Espinosa Nov 23 '16 at 17:21
  • I am generating the image in HTML manner, I do not have an image that I display in a canvas. Therefor I use third party libraries so that I can generated (based on some computing logics what to be drawn). These libraries are using svg over canvas (I do believe it is for a reason). – Milen Igrachev Nov 23 '16 at 17:25
  • Svg is a perfectly fine image format. Why not just use that? – Holger Will Nov 23 '16 at 19:22
  • @HolgerWill I am using http://www.w3schools.com/html/html5_svg.asp not a file. – Milen Igrachev Nov 23 '16 at 21:23

0 Answers0