Created
September 7, 2013 23:48
-
-
Save zz85/6480535 to your computer and use it in GitHub Desktop.
Offline Rendering of @kig's Message presentation app using SlimerJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
PDF Generator for @ilmarihei's Awesome "Messsage" Presentation App! | |
Usage: | |
./slimerjs messages.js | |
You may also need to | |
- get http://slimerjs.org/ | |
- edit the config variables | |
- run `convert slides/*.jpg presentation.pdf` | |
Cheers, | |
@blurspline | |
*/ | |
var TARGET = 'https://viewmessage.fhtr.net/?page=view&id=51dad76876241f0200000002' | |
var SCREEN_SHOT_DELAY = 1000; | |
var WIDTH = 1024; | |
var HEIGHT = 768; | |
console.log("Hello Messages PDF Generator!"); | |
var webpage = require("webpage"); | |
var page = webpage.create(); | |
var downloaded = {}; | |
page.onConsoleMessage = function (msg) { | |
console.log(msg); | |
var match = msg.match(/Slide[ ](\d+)\/(\d+)/); | |
if (match && match.length == 3) { | |
if (match[1] in downloaded) return; | |
downloaded[match[1]] = true; | |
console.log(match); | |
setTimeout(function() { | |
page.render('slides/' + match[1] + '.jpg', { format: "jpg", quality: 100 }); | |
page.sendEvent('keyup', page.event.key.Right); | |
if (match[1] == match[2]) { | |
console.log('last slide.') | |
page.end() | |
phantomjs.exit(); | |
return; | |
} | |
}, SCREEN_SHOT_DELAY); | |
} | |
}; | |
page.onResourceReceived = function (response) { | |
if (response.stage=='end') console.log('downloaded: ' + response.url) | |
}; | |
page.viewportSize = { width: WIDTH, height: HEIGHT }; | |
page.open(TARGET); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment