Closed lsa-pilot closed 8 years ago
Hello,
SVG2Bitmap doesn't offer any saving method.
Browsers implementations are too complex to offer a simple way, so we just give the canvas (or its dataURL representation when available), but we won't implement any saving feature. Sorry.
What you can do however, is to use something like FileSaver.js, that you'll be able to use like this :
SVG2Bitmap(elt, function(canvas){
canvas.toBlob(function(blob) {
saveAs(blob, "area_chart.png");
});
}, {backgroundColor: 'white'} );
Hi @Kaiido; I use your script to convert svg to png, then allow download in Chrome, but the filename is always set by default to "download.png". In order to set a different name, I tried to add a filename property to your script, but could not figure out where or how to do it. This is how I call your script:
function renderAsPNG(eltId) { var elt = document.getElementById(eltId); SVG2Bitmap(elt, undefined, {backgroundColor: 'white', filename: 'area_chart'}); }