UNPKG

645 BJavaScriptView Raw
1var NodePDF = require('nodepdf');
2
3// last argument is optional, sets the width and height for the viewport to render the pdf from. (see additional options)
4var pdf = new NodePDF('http://www.google.com', 'google.pdf', {
5 'viewportSize': {
6 'width': 1440,
7 'height': 900
8 },
9 'args': '--debug=true'
10});
11
12pdf.on('error', function(msg){
13 console.log(msg);
14});
15
16pdf.on('done', function(pathToFile){
17 console.log(pathToFile);
18});
19
20// listen for stdout from phantomjs
21pdf.on('stdout', function(stdout){
22 // handle
23});
24
25// listen for stderr from phantomjs
26pdf.on('stderr', function(stderr){
27 // handle
28});
\No newline at end of file