Skip to content

Instantly share code, notes, and snippets.

@marcelaraujo
Created July 21, 2015 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelaraujo/317798da1aa900a350b6 to your computer and use it in GitHub Desktop.
Save marcelaraujo/317798da1aa900a350b6 to your computer and use it in GitHub Desktop.
PhantomJS /dev/stdin -> /dev/stdout
var page = require('webpage').create(),
system = require('system'),
fs = require('fs');
var input = system.stdin.read();
page.viewportSize = {
width: 1280,
height: 1000
};
page.paperSize = {
format: 'A4',
margin: '20px'
};
page.onLoadFinished = function(status) {
page.render('/dev/stdout', {format: 'pdf'});
phantom.exit(0);
};
page.setContent(input, 'http://localhost');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment