AuburnBigEvent/BigEvent — pull request #15 by CoryG89 (2013-11-04 18:03:12+00:00)
Title: Adding PDF generation module and mocha test

This adds a PDF generation module that I developed yesterday. It's based on [PhantomJS](http://phantomjs.org/) which is a [headless browser](http://blog.arhg.net/2009/10/what-is-headless-browser.html) based on Webkit (base for Safari/Chromium as well). PhantomJS is something that has to run separately on a system from our Node server, this is also the case for all other feasible PDF generation solutions that I was able to find except one. The benefit with PhantomJS however, is that it can be installed by NPM as the `phantomjs` module as a local application dependency so we can list it in our `package.json` file and have NPM manage it with all our other dependencies. I use the `node-phantom` module which starts the local PhantomJS installation as a child process and uses it throughout the life of the server to generate PDFs. The `node-phantom` module exposes a completely asynchronous message based interface to the local PhantomJS install in `./node_modules/phantomjs` running as a child process. Using PhantomJS I can then create pages from HTML after rendering them as templates with EJS, then use PhantomJS to render that page as PDF file. Instead of creating a new page in PhantomJS, to not waste memory we reuse the same page, injecting new content each time and re-rendering a new PDF.