1 | var 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)
|
4 | var pdf = new NodePDF('http://www.google.com', 'google.pdf', {
|
5 | 'viewportSize': {
|
6 | 'width': 1440,
|
7 | 'height': 900
|
8 | },
|
9 | 'args': '--debug=true'
|
10 | });
|
11 |
|
12 | pdf.on('error', function(msg){
|
13 | console.log(msg);
|
14 | });
|
15 |
|
16 | pdf.on('done', function(pathToFile){
|
17 | console.log(pathToFile);
|
18 | });
|
19 |
|
20 | // listen for stdout from phantomjs
|
21 | pdf.on('stdout', function(stdout){
|
22 | // handle
|
23 | });
|
24 |
|
25 | // listen for stderr from phantomjs
|
26 | pdf.on('stderr', function(stderr){
|
27 | // handle
|
28 | }); |
\ | No newline at end of file |