Skip to content
Browse files

Extend printheaderfooter.js example documentation

The comment now explains how to delegate the header/footer setup
to the loaded HTML page by giving an explicit HTML example that
defines the required PhantomJSPrinting object

ISSUE: 512 (http://code.google.com/p/phantomjs/issues/detail?id=512)
  • Loading branch information...
1 parent 2c4e7b6 commit a38eab143aa2463659cc8922db1e2b20116287dc @milianw milianw committed Apr 25, 2012
Showing with 21 additions and 2 deletions.
  1. +21 −2 examples/printheaderfooter.js
View
23 examples/printheaderfooter.js
@@ -41,11 +41,30 @@ if (system.args.length < 3) {
} else {
/* check whether the loaded page overwrites the header/footer setting,
i.e. whether a PhantomJSPriting object exists. Use that then instead
- of our defaults above. */
+ of our defaults above.
+
+ example:
+ <html>
+ <head>
+ <script type="text/javascript">
+ var PhantomJSPrinting = {
+ header: {
+ height: "1cm",
+ contents: function(pageNum, numPages) { return pageNum + "/" + numPages; }
+ },
+ footer: {
+ height: "1cm",
+ contents: function(pageNum, numPages) { return pageNum + "/" + numPages; }
+ }
+ };
+ </script>
+ </head>
+ <body><h1>asdfadsf</h1><p>asdfadsfycvx</p></body>
+ </html>
+ */
if (page.evaluate(function(){return typeof PhantomJSPrinting == "object";})) {
paperSize = page.paperSize;
paperSize.header.height = page.evaluate(function() {
- console.log("woot?", PhantomJSPrinting.header.height);
return PhantomJSPrinting.header.height;
});
paperSize.header.contents = phantom.callback(function(pageNum, numPages) {

0 comments on commit a38eab1

Please sign in to comment.
Something went wrong with that request. Please try again.