Can anyone tell me why is my svg to png not downloading? What am I doing wrong? I can't seem to find a solution on how to download my svg to png. Is it my libraries or my code?
function save(){
$("#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...
});
}
<script src="canvg-master/canvg.js"></script>
<div id="editor" class="chart">
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="red" />
</svg><br />
<button id="editor_save" onclick="save">Save</button>
</div>