Reputation: 1579
I created a chart in d3. According to my requirement, I have to allow for downloading as PNG in all browsers. I am using saveSvgAsPng.js for that.
saveSvgAsPng(document.getElementById("sample"), "sample.png", { width: '50%' });
I am able to download it in Chrome and Firefox, but I am not able to download in IE.
On checking console, I get below errors:
Unknown font format for https://fonts.googleapis.com/css?family=Karla; Fonts may not be working correctly
Rendered SVG images cannot be downloaded in this browser.
I do not know if I missed any parameters to pass in.
Upvotes: 3
Views: 1500
Reputation: 1054
As per saveSvgAsPng GitHub
Internet Explorer will only work if canvg is passed in, otherwise it will throw a SecurityError when calling toDataURL on a canvas that's been written to. [...]
So you must include your script canvg and then pass it as a parameter
var svg = document.querySelector('sample');
saveSvgAsPng(svg, "sample.png", {canvg:window.canvg});
Upvotes: 1