Skip to main content
A header or footer is one of four shapes: a single block, an array of blocks, a function of page context, or a raw draw callback. Functions run per page at build time.

Page context

A function header or footer receives the page context, and a raw draw receives a draw area that extends it with the zone rectangle.

Setting them

Set a header or footer document wide with doc.set_header and doc.set_footer, or per page through doc.page({ header, footer }). A function runs once per page, so it can read the current page number and total count.

Raw draw header

A RawDraw declares a height and a draw callback. The callback receives the live pdfkit document and the zone rectangle, so you can draw vector graphics directly.
Per page headers and footers override the document wide ones for that page. Pass them through doc.page({ header, footer }).