exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

Throws security error on safari 9 when svg has foreignObject element #132

Closed g1aurav closed 6 years ago

g1aurav commented 7 years ago

I am calling the saveSvgAsPng in my javascript like this saveSvgAsPng(dashboardVm.chartSvg, "diagram.png", {backgroundColor: 'white'}). It works fine on chrome and I am able to download the png, but on safari 9 I get this error, Error: SecurityError: DOM Exception 18. I have a foreignObject element in my svg and I think it is causing this problem. Is there a workaround for this issue?

exupero commented 7 years ago

I don't know of any workaround. Can you confirm that it's caused by the foreignObject by removing it and seeing if the SecurityError goes away?

g1aurav commented 7 years ago

It doesn't throw any error anymore but the png isn't downloaded either. Download works in this case too on chrome.

deepxg commented 7 years ago

I'm getting this error on images with data URLs, which I believe might be rendered by the new font-handling code, as they're normal images in my SVG.

exupero commented 7 years ago

Images are inlined to data URLs, otherwise they aren't included in the final PNG.

It's possible that it is caused by custom font handling. To verify, please roll back to 3478b865304ff62d2316e663f928902d8eca8a2c and see if the error is there as well.

exupero commented 6 years ago

Closing due to inactivity.