brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 285 forks source link

Added support for pageSize.header.contents and pageSize.footer.contents #232

Closed lukeacl closed 2 months ago

lukeacl commented 6 years ago

Because you can't pass a phantom.callback to pageSize.header.contents or pageSize.footer.contents I've added functionality to instead use a string passed to these properties as a template build them into a phantom.callback on the other side.

Two placeholders {pageNumber} and {numberOfPages} are available and replaced on the fly, these come from the phantom callback context.

For example:

header: {
  height: "3cm",
  contents: "<span style=\"font-family: sans-serif;\">Header - {pageNumber}/{numberOfPages}<span>"
},
footer: {
  height: "1cm",
  contents: "<span>Footer - {pageNumber}/{numberOfPages}<span>"
}

I've also adjusted the doc to cover this.