-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientPdf.js
More file actions
24 lines (21 loc) · 792 Bytes
/
clientPdf.js
File metadata and controls
24 lines (21 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var screenshotmachine = require('screenshotmachine');
var customerKey = 'PUT_YOUR_CUSTOMER_KEY_HERE';
secretPhrase = ''; //leave secret phrase empty, if not needed
options = {
//mandatory parameter
url : 'https://www.google.com',
// all next parameters are optional, see our website to PDF API guide for more details
paper : 'letter',
orientation : 'portrait',
media: 'print',
bg: 'nobg',
delay: '2000',
scale: '50'
}
var pdfApiUrl = screenshotmachine.generatePdfApiUrl(customerKey, secretPhrase, options);
//save PDF file
var fs = require('fs');
var output = 'output.pdf';
screenshotmachine.readScreenshot(pdfApiUrl).pipe(fs.createWriteStream(output).on('close', function() {
console.log('Pdf saved as ' + output);
}));