Skip to content

Instantly share code, notes, and snippets.

@JamesMGreene
Forked from ahomu/shot.js
Created October 21, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesMGreene/3928230 to your computer and use it in GitHub Desktop.
Save JamesMGreene/3928230 to your computer and use it in GitHub Desktop.
Create slides(Reveal.js) PNG images using phantomjs
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://localhost:1947/';
page.viewportSize = {
width: 1024,
height: 768
};
page.open(url, function (status) {
//Page is loaded!
var iz, i = 0, queue = {};
iz = page.evaluate(function() {
return document.querySelector('.slides').children.length;
});
console.log('total '+iz+' pages!');
function createQueue(i) {
return function() {
console.log('rendering page of '+i+' ..............');
page.evaluate(function(i) {
Reveal.navigateTo(i);
}, i);
// waiting transition
setTimeout(function() {
var next = queue[(i+1)];
page.render('./shot/shot-'+i+'.png');
if (next) {
next();
} else {
phantom.exit();
}
console.log('done '+i+'.');
}, 1000);
};
}
for (; i<iz; i++) {
queue[i] = createQueue(i);
}
queue[0]();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment