-
Notifications
You must be signed in to change notification settings - Fork 9
/
pdf.js
35 lines (32 loc) · 833 Bytes
/
pdf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
console.log("Printing PDF");
var system = require('system');
console.log("Commandline arguments: " + system.args);
console.log("Number of commandline arguments: " + system.args.length);
if(system.args.length < 3){
console.log("Please supply the input html resume and the output pdf file.");
phantom.exit();
}
else{
console.log("You have enough arguments!");
var page = require('webpage').create();
var htmlFile = system.args[1];
var outputPdfFile = system.args[2];
page.paperSize = {
format: 'Letter',
orientation: 'portrait',
margin: '0.4in'
};
page.open(htmlFile, function(status){
if(status !== 'success'){
console.log("Failed to load page!");
phantom.exit();
}
else{
console.log("Successfully loaded page!");
page.render(outputPdfFile, {
format: "pdf"
});
phantom.exit();
}
});
}