How to download SVG in IE11 and save it locally in PNG format?

problem description

there is a SVG graphic. If you want to download it locally by clicking a button, the IE is not compatible.

the environmental background of the problems and what methods you have tried

my idea is to convert SVG to canvas, first through canvas.msToBlob (), window.navigator.msSaveBlob (blob, "svg.png"); to download, but not to canvas during operation.
has tried the plug-in canvg.js, but will report an error under IE.

let canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
let svgHtml=document.getElementById("container").innerHTML.trim();
canvg(canvas,svgHtml);

let blob = canvas.msToBlob ();
window.navigator.msSaveBlob (blob, "svg.png");

clipboard.png

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

is there a master who can solve this problem

May.11,2021

or right-click to save as useful

Menu