I'm trying to code a javascript function that takes a Highcharts image, converts it to canvas, and downloads the file image locally (without going to the server).
My problem is specifically with IE. I tried using msSaveBlob with Blob and MSBlobBuilder; in the first case the file downloads however the content is incorrect (the image is damaged when opened).
Fist code uses Blob/msSaveBlob (see jsfiddle, run with IE):
var image = canvas.toDataURL("image/jpeg");
if (navigator.msSaveBlob) {
return navigator.msSaveBlob(new Blob([image],{type:"image/jpeg"}),"file23.jpeg");
}
Second code uses MSBlobBuilder/msSaveBlob but doesn't generate a file (see jsfiddle, run with IE):
var image = canvas.toDataURL("image/jpeg");
if (window.MSBlobBuilder) {
var bb = new MSBlobBuilder();
bb.append(image);
return navigator.msSaveBlob(bb, "file24.jpeg");
}
Any ideas how to make any of these work? Is there a preferred method? I understand this will work for IE10+ only.