## phantom.net
For nodejs developers wanting to run phantomjs as a network service. Includes both server and client library.
server
start a phantom.net service on port 5000.
var phantom = var server = 5000
client
connect to service and render web page as pdf.
var phantom = var client = 'http://localhost:5000' var parameter = url: 'http://google.com' mime: 'application/pdf' client
install
npm install phantom.net
note: phantomjs needs to be installed on the server machine, and set up as a PATH environment variable.
contents ### overview
phantom.net was written specifically for developers looking to expose phantomjs as a network service. The library allows developers to quickly host phantomjs as a http accessible endpoint, and pass it urls and content to render. phantom.net will respond with readable streams. Useful for writing results to disk, or back out as http response.
### rendervar phantom = var client = 'http://localhost:5000' var parameter = url: 'http://google.com' mime: 'application/pdf' client
The client render() method accepts a single parameter which is passed to phantomjs for rendering. Below is the parameter definition. When passing this parameter, either url or content must be set. The mime is required, and can be either 'application/pdf', image/jpg', 'image/png' or 'image/gif'
note: for more details on the following properties, see here.
By default, phantom.net will wait 200ms for a page to render. A client can modify this value to increase the allowed for the page to load. The following will wait 2 seconds.
var phantom = var client = 'http://localhost:5000' client
By default, the phantom.net server will put limits on waiting (the default is 4 seconds), however you can override the maximum wait as follows...
var phantom = var server = 5000 maximum_wait: 10000
var phantom = var server = 5001 var client = "http://localhost:5001" console
If running the server on a windows machine, rendering may take a considerable amount of time. If this is a issue, you can speed things up unchecking 'automatically detect settings' in internet explorers LAN settings, as follows...
- open up internet explorer.
- options > internet options > connections (tab).
- uncheck 'automatically detect settings'.
- click ok.