0

This is a requirement I had to solve so I thought I would post the solution I used for others.

I needed a button that would allow me to save a VivaGraph SVG rendering as PNG.

Tutan Ramen
  • 1,234
  • 1
  • 8
  • 27

1 Answers1

0

If you use: https://github.com/exupero/saveSvgAsPng It worked perfectly for me.

The only file you need is saveSvgAsPng.js

If you include that in your html you can call it like so:

window.saveSvgAsPng(document.getElementById("svgID"), "export.png");

Wire it up to some handler and when you invoke it you should see export.png as a download.

NOTE: Your mileage may vary. The author of the github repo said that it may not render everything verbatim for all cases. For my case it rendered a transparent PNG perfectly.

NOTE: Also this doesn't work in IE if that's a requirement for you

Community
  • 1
  • 1
Tutan Ramen
  • 1,234
  • 1
  • 8
  • 27