var svgElement = document.getElementById('my-svg');
document.getElementById('convertBtn').onclick = function(){
var simg = new Simg(svgElement);
// Replace the current SVG with an image version of it.
simg.replace();
// And trigger a download of the rendered image.
simg.download();
};
Thank you to @headwinds for creating this example page.