-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.js
63 lines (46 loc) · 1.07 KB
/
make.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var page = require('webpage').create(),
system = require('system'),
url = system.args[1];
console.log('---');
if (url) {
page.open(url, function (s) {
var title = 'slide',
pages,
session,
fileName;
pages = page.evaluate(function() {
var item,
i,
tb = document.querySelectorAll('.to-build');
for(i in tb){
item = tb[i];
if(item.classList)
item.classList.remove('to-build','');
}
return document.querySelectorAll("article").length;
});
page.viewportSize = { width: 1024, height: 768 };
page.paperSize = {
format: 'A4', orientation: 'landscape', margin: '0px',
}
for(var x = 1; x <= pages; x++) {
console.log("- Generating page " + x);
fileName = title + "-" + x + ".pdf";
// fileName = title + ".pdf";
if(!session)
session = page.render(fileName)
else
page.render(fileName, session);
page.evaluate(function(){
curSlide++;
updateSlides();
});
}
console.log('---');
phantom.exit();
});
} else {
console.log('Try: phantomjs make.js [url]');
console.log('---');
phantom.exit();
}