diff --git a/_posts/api/webpage/property/2000-01-01-paper-size.md b/_posts/api/webpage/property/2000-01-01-paper-size.md index 1e4d6850..d23f5c43 100644 --- a/_posts/api/webpage/property/2000-01-01-paper-size.md +++ b/_posts/api/webpage/property/2000-01-01-paper-size.md @@ -31,6 +31,20 @@ Supported formats are: `'A3'`, `'A4'`, `'A5'`, `'Legal'`, `'Letter'`, `'Tabloid' Orientation (`'portrait'`, `'landscape'`) is optional and defaults to `'portrait'`. +### Headers and Footers + +A repeating page header and footer can also be added via the header and footer property. These can be provided as an object that contains a `height` and a `contents` property. The contents property must be set as a phantom.callback object. + +```javascript +header: { + height: "1.2cm", + contents: phantom.callback(function(pageNum, numPages) { + return "

Header " + pageNum + " / " + numPages + "

"; + }) +} +``` + + ## Acceptable Objects The given object should be in _either_ this format: @@ -68,6 +82,29 @@ page.paperSize = { }; ``` +A repeating page `header` and `footer` can also be added via this property, as in [this example](https://github.com/ariya/phantomjs/blob/master/examples/printheaderfooter.js): +```javascript +var webPage = require('webpage'); +var page = webPage.create(); + +page.paperSize = { + width: '8.5in', + height: '11in', + header: { + height: "1cm", + contents: phantom.callback(function(pageNum, numPages) { + return "

Header " + pageNum + " / " + numPages + "

"; + }) + }, + footer: { + height: "1cm", + contents: phantom.callback(function(pageNum, numPages) { + return "

Footer " + pageNum + " / " + numPages + "

"; + }) + } +} +``` +