I'm writing an app that lets users generate images with Raphael.JS. One of the secondary features I want is to generate a PNG of the Raphael canvas.
Here's the general pipeline in my head:
- User inputs parameters
- We generate JS with Raphael calls
- We generate a JS wrapper that does the above and calls .innerHTML on the containing div, giving us SVG (which we then send somewhere)
- We execute the JS wrapper
- The SVG is sent to ImageMagick and out pops a PNG
Step 4 is the step I need some guidance on. The user could be using IE; we have no guarantee that the JS is ever executed in an SVG browser. In any case, we'd need this to run server-side for it to be reliable. So here are the three possibilities I've come up with so far:
- Install Firefox on the server and run the result of (3) in Firefox. This option sucks because installing FF means installing a bunch of X stuff on our server, running FF carries a lot of overhead, and I don't really want to muck about with tracking the process and killing it once it's done.
- Use Node.js + jsdom (http://github.com/tmpvar/jsdom). Downside here is that it's not clear how supported jsdom is - the purported site, jsdom.org, doesn't really exist. Also, I can't find any documentation.
- Maybe do something with Rhino? As far as I can tell, Rhino has even more meager DOM support than Node.
So...all three of those options kind of suck. I think. Am I wrong about something? Is there another way?