I'm using Raphael SketchPad to create the SVG. Link to the file from step 1.
For the "Save" button (the id of svg is "editor" and the id of canvas is "canvas"):
$("#editor_save").click(function() {
// the canvg call that takes the svg xml and converts it to a canvas
canvg('canvas', $("#editor").html());
// the canvas calls to output a png
var canvas = document.getElementById("canvas");
var img = canvas.toDataURL("image/png");
// do what you want with the base64, write to screen, post to server, etc...
});
jbeard4 solution works well.
I'm using Raphael SketchPad to create the SVG. Link to the file from step 1.
For the "Save" button (the id of svg is "editor" and the id of canvas is "canvas"):
The following is the method implemented through JavaScript: