Skip to content

Instantly share code, notes, and snippets.

@TJkrusinski
Last active August 29, 2015 13:57
Show Gist options
  • Save TJkrusinski/9529620 to your computer and use it in GitHub Desktop.
Save TJkrusinski/9529620 to your computer and use it in GitHub Desktop.
var NodePDF = require('nodepdf');
// last argument is optional, sets the width and height for the viewport to render the pdf from. (see additional options)
var pdf = new NodePDF('http://www.yahoo.com', 'yahoo.pdf', {
'viewportSize': {
'width': 1440,
'height': 900
},
'args': '--debug=true'
});
pdf.on('error', function(msg){
console.log(msg);
});
pdf.on('done', function(pathToFile){
console.log(pathToFile);
});
// listen for stdout from phantomjs
pdf.on('stdout', function(stdout){
// handle
});
// listen for stderr from phantomjs
pdf.on('stderr', function(stderr){
// handle
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment