Created
February 8, 2014 14:47
-
-
Save bojoer/8884812 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// html2pdf.js | |
var page = new WebPage(); | |
var system = require("system"); | |
// change the paper size to letter, add some borders | |
// add a footer callback showing page numbers | |
page.paperSize = { | |
format: "A4", | |
orientation: "portrait", | |
footer: { | |
height: "0.9cm", | |
contents: phantom.callback(function (pageNum, numPages) { | |
return "<div style='text-align:center;'><small>" + pageNum + | |
" / " + numPages + "</small></div>"; | |
}) | |
} | |
}; | |
page.zoomFactor = 1; | |
// assume the file is local, so we don't handle status errors | |
page.open(system.args[1], function (status) { | |
page.render(system.args[2]); | |
phantom.exit(); | |
}); | |
// phantomjs html2pdf.js invoice.html invoice.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment