Skip to content

Instantly share code, notes, and snippets.

@revolunet
Created January 9, 2012 12:29
Show Gist options
  • Select an option

  • Save revolunet/1582739 to your computer and use it in GitHub Desktop.

Select an option

Save revolunet/1582739 to your computer and use it in GitHub Desktop.
use phantomjs to get pngs from your dzslides presentation
//
// this outputs a png file for each section in your presentation
// then use `convert slide-*.png output.pdf` to create single PDF
//
function screenshot(url, output) {
var page = new WebPage();
page.viewportSize = { width: 1000, height: 700 };
page.onConsoleMessage = function (msg, line, source) {
console.log('console> ' + msg);
};
page.onAlert = function (msg) {
console.log('alert!!> ' + msg);
};
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
window.setTimeout(function () {
page.render(output);
getNextPage();
},1000);
}
});
}
var base_url = 'http://www.revolunet.com/static/paug2011/#';
var counter = 1;
function getNextPage() {
if (counter>41) {
console.log('finished');
phantom.exit();
}
var num = counter + '.0';
if (counter==4) num='4.8';
else if (counter==11) num='11.5';
else if (counter==33) num='33.2';
console.log(base_url+num);
screenshot(base_url+num, 'screenshots/slide-'+num+'.png');
counter+=1;
}
getNextPage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment