Skip to content

Instantly share code, notes, and snippets.

@mickaelandrieu
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mickaelandrieu/9010026 to your computer and use it in GitHub Desktop.
Save mickaelandrieu/9010026 to your computer and use it in GitHub Desktop.
/**
* @author Mickaël Andrieu <mickael.andrieu@sensiolabs.com>
* @licence MIT
* Usage: casperjs casperPDF.js "[url]" [filename.<format>]
*/
var casper = require('casper').create({
pageSettings: {
paperSize: {
format: "Letter",
orientation: "portrait",
margin: {left:"2.5cm", right:"2.5cm", top:"1cm", bottom:"1cm"},
footer: {
height: "0.9cm"
/* contents: casper.phantom.callback(function(pageNum, numPages) {
return "<div style='text-align:center;'><small>" + pageNum +
" / " + numPages + "</small></div>";
}) -> throws an error because we don't have access to phantom at this point */
} // The WebPage instance used by Casper will
},
zoomFactor: 1.5
}
});
var url = casper.cli.get(0);
var output = casper.cli.get(1);
casper.start();
casper.thenOpen(url, function (status) {
casper.capture(output);
});
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment