Skip to content

Instantly share code, notes, and snippets.

@eduardolundgren
Created December 31, 2013 15:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardolundgren/8198093 to your computer and use it in GitHub Desktop.
Save eduardolundgren/8198093 to your computer and use it in GitHub Desktop.
function html2pdf(path, outputPath, opt_callback) {
phantom.create(function(ph) {
ph.createPage(function(page) {
page.set('paperSize', {
format: 'A4',
orientation: 'portrait'
});
page.open(path, function() {
setTimeout(function() {
page.render(outputPath, function() {
page.close();
ph.exit();
opt_callback && opt_callback();
});
}, 100);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment