Skip to content

Instantly share code, notes, and snippets.

Created July 10, 2014 21:54
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 anonymous/438bc353879661638d6f to your computer and use it in GitHub Desktop.
Save anonymous/438bc353879661638d6f to your computer and use it in GitHub Desktop.
var webpage = require('webpage');
var page = webpage.create();
page.open('http://example.com/', function(status){
var b64 = page.renderBase64('PNG');
console.log(typeof b64.image);
page.evaluate(function(b64){
for(var i = 0; i < 100; i++)
document.write('<img src="data:image/png;base64,'+b64+'">');
}, b64);
setTimeout(function(){
page.render('test08_b64example.pdf');
page.render('test08_b64example.png');
console.log("DONE");
phantom.exit();
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment