0

i'm running a rails app and trying to get a screenshot of an nvd3 graph in-browser.

from my testing, canvg and html2canvas can't render the css that accompanies nvd3. has anyone been able to create a png from an nvd3 svg?

html2canvas example - try rendering the nvd3 scatter on html2canvas preview. it's not working...

any ideas?

bumpkin
  • 3,321
  • 4
  • 25
  • 32
  • [This question](http://stackoverflow.com/questions/11632748/svg-to-png-server-side-using-node-js) should help if you can do it on the server. – Lars Kotthoff Nov 14 '13 at 09:15
  • Further reading, [this](https://github.com/ariya/phantomjs/wiki/Screen-Capture) page from phantomJS wiki and [this](https://github.com/ariya/phantomjs/wiki/Related-Projects#screenshot-utilities) collection of screen grab utilities might help. – WolfgangCodes Nov 14 '13 at 12:22
  • isn't phantomJS a terminal utility? how would i use it in-browser? – bumpkin Nov 14 '13 at 14:31

1 Answers1

0

from the html2canvas FAQ we know that it cannot properly deal with svg.

i have very similar requirement and "example of how to export a png directly from an svg" solved my problem (internally it adopted svg-crowbar code). basically, you need to draw the svg to a canvas then export the image to png, and "explicitly set css style" for all svg element is the caveat to make the exported image like original.

Dyno Fu
  • 8,753
  • 4
  • 39
  • 64