pdfmake gives you full control over the repeating elements that appear on every page of your document. Headers, footers, background layers, and watermarks can all be defined once in the document definition and pdfmake will render them automatically on each page — with access to the current page number, total page count, and page dimensions so you can make them truly dynamic.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/bpampuch/pdfmake/llms.txt
Use this file to discover all available pages before exploring further.
Header and Footer
Theheader and footer properties sit at the top level of your document definition. Each can be either a static content node (a string, an object, or an array) or a function that receives the current page number, total page count, and page size, then returns a content node.
(currentPage, pageCount, pageSize) => content. The pageSize argument is an object with width and height properties, which is useful when your document mixes page sizes or orientations.
Headers and footers are rendered outside the page margins. Use the
margin property on the returned content node to position them correctly within the printable area.Returning Arrays from Header/Footer Functions
You can return any valid pdfmake content node — including an array of items or a complex layout object — from a header or footer function.Conditional Headers by Page
Because the header and footer are functions, you can skip them on specific pages by returningnull or an empty string.
Background Layer
Thebackground property lets you render content behind the main page content on every page. Like header and footer, it accepts a static value or a function — (currentPage, pageSize) => content.
Watermarks
A watermark is diagonal text stamped across every page. Define it using thewatermark property directly on the document definition.
The watermark text to display.
Font family name. Defaults to the document default font (e.g.
'Roboto').Font size in points. pdfmake auto-scales if omitted.
Whether to render the text bold.
Whether to render the text in italics.
CSS color string (e.g.
'blue', '#FF0000').Opacity between
0 (invisible) and 1 (fully opaque). Values like 0.3 work well for watermarks.Rotation angle in degrees. Defaults to a diagonal angle if omitted.
Document Sections
pdfmake supports sections — groups of pages within a document that each carry their own header, footer, background, watermark, page size, orientation, and margins. Sections let you have a landscape chart section inside an otherwise portrait report, or a title page with no header at all. Sections live inside thecontent array as objects with a section key containing their page content:
Section Property Inheritance
Override with a value
Set
header, footer, background, or watermark to a new value (or function) to replace the document-level default for that section’s pages.Suppress with null
Set any of these to
null to disable them entirely for that section, even if the document defines a default.Inherit from previous
Set any of
header, footer, background, or watermark to 'inherit' (or pageSize: 'inherit', pageOrientation: 'inherit', pageMargins: 'inherit') to reuse whatever the previous section used.Fall through to document
Omitting a property causes the section to fall back to the document-level setting automatically.