pdfmake gives you full control over the physical shape of your document. You can choose from dozens of standard paper sizes, rotate the page, fine-tune margins, and even switch page settings mid-document using sections. All of these are top-level keys in your document definition object.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.
pageSize — Choosing a paper size
Set pageSize to a string matching one of pdfmake’s built-in size names, or supply a custom { width, height } object. Dimensions in the built-in table are given in PDF points (1 pt ≈ 0.353 mm).
Standard page sizes
pdfmake ships with the following named sizes, sourced directly fromstandardPageSizes.js:
| Name | Width (pt) | Height (pt) | Common use |
|---|---|---|---|
4A0 | 4767.87 | 6740.79 | Large-format printing |
2A0 | 3370.39 | 4767.87 | Large-format printing |
A0 | 2383.94 | 3370.39 | Posters |
A1 | 1683.78 | 2383.94 | Posters |
A2 | 1190.55 | 1683.78 | Technical drawings |
A3 | 841.89 | 1190.55 | Spreadsheets |
A4 | 595.28 | 841.89 | Standard document (default) |
A5 | 419.53 | 595.28 | Booklets |
A6 | 297.64 | 419.53 | Postcards |
A7 | 209.76 | 297.64 | Notes |
A8 | 147.40 | 209.76 | Business cards |
A9 | 104.88 | 147.40 | Labels |
A10 | 73.70 | 104.88 | Labels |
B0 | 2834.65 | 4008.19 | ISO B series |
B1 | 2004.09 | 2834.65 | ISO B series |
B2 | 1417.32 | 2004.09 | ISO B series |
B3 | 1000.63 | 1417.32 | ISO B series |
B4 | 708.66 | 1000.63 | ISO B series |
B5 | 498.90 | 708.66 | Books |
B6 | 354.33 | 498.90 | ISO B series |
B7 | 249.45 | 354.33 | ISO B series |
B8 | 175.75 | 249.45 | ISO B series |
B9 | 124.72 | 175.75 | ISO B series |
B10 | 87.87 | 124.72 | ISO B series |
C0 | 2599.37 | 3676.54 | ISO C (envelope) series |
C1 | 1836.85 | 2599.37 | ISO C series |
C2 | 1298.27 | 1836.85 | ISO C series |
C3 | 918.43 | 1298.27 | ISO C series |
C4 | 649.13 | 918.43 | Envelopes for A4 |
C5 | 459.21 | 649.13 | Envelopes for A5 |
C6 | 323.15 | 459.21 | Envelopes for A6 |
C7 | 229.61 | 323.15 | ISO C series |
C8 | 161.57 | 229.61 | ISO C series |
C9 | 113.39 | 161.57 | ISO C series |
C10 | 79.37 | 113.39 | ISO C series |
RA0 | 2437.80 | 3458.27 | Raw (untrimmed) A series |
RA1 | 1729.13 | 2437.80 | Raw A series |
RA2 | 1218.90 | 1729.13 | Raw A series |
RA3 | 864.57 | 1218.90 | Raw A series |
RA4 | 609.45 | 864.57 | Raw A series |
SRA0 | 2551.18 | 3628.35 | Supplementary raw A |
SRA1 | 1814.17 | 2551.18 | Supplementary raw A |
SRA2 | 1275.59 | 1814.17 | Supplementary raw A |
SRA3 | 907.09 | 1275.59 | Supplementary raw A |
SRA4 | 637.80 | 907.09 | Supplementary raw A |
EXECUTIVE | 521.86 | 756.00 | US Executive |
FOLIO | 612.00 | 936.00 | US Folio |
LEGAL | 612.00 | 1008.00 | US Legal |
LETTER | 612.00 | 792.00 | US Letter |
TABLOID | 792.00 | 1224.00 | US Tabloid / Ledger |
Custom page size
Pass an object with explicitwidth and height values (in PDF points) to define a non-standard page size:
PDF points are the native unit pdfmake uses internally. To convert from millimetres:
pt = mm * 2.8346.pageOrientation — Portrait or landscape
Set pageOrientation to 'portrait' (default) or 'landscape'. When set to 'landscape', pdfmake swaps the width and height of the chosen page size:
pageMargins — Controlling white space
pageMargins defines the inset from each edge of the page to the content area. It accepts three forms:
pageMargins is omitted, pdfmake uses a built-in default margin.
Document sections
For advanced documents that mix page sizes, orientations, or per-section headers and footers, pdfmake supports sections. A section is a content node with asection array in place of the usual node-type key. Each section node can override pageSize, pageOrientation, pageMargins, header, footer, background, and watermark.
The following example is drawn directly from examples/sections.js:
Setting a section property to the string
'inherit' explicitly copies that setting from the previous section. Setting it to null removes the inherited value (e.g., suppresses the document watermark for that section).Section override precedence
Each section can specify its own values for:| Property | Description |
|---|---|
pageSize | Paper size for this section’s pages |
pageOrientation | 'portrait', 'landscape', or 'inherit' |
pageMargins | Margins for this section’s pages |
header | Header function, null to suppress, or omit to use the document default |
footer | Footer function, null to suppress, or omit to use the document default |
background | Background function, null to suppress |
watermark | Watermark text/object, null to suppress, 'inherit' to copy previous |
pageBreakBefore callback
The pageBreakBefore function at the document level lets you insert dynamic page breaks based on context. pdfmake calls it before placing each node and passes the node’s info along with an object containing three lazy getter functions. Return true to force a page break before that node:
| Argument | Description |
|---|---|
currentNode | The node info object pdfmake is about to place |
getFollowingNodesOnPage() | Lazy getter — returns nodes already assigned to the current page after currentNode |
getNodesOnNextPage() | Lazy getter — returns nodes that will flow onto the next page |
getPreviousNodesOnPage() | Lazy getter — returns nodes already placed on the current page before currentNode |
The three context helpers are getter functions, not plain arrays. Always call them —
getFollowingNodesOnPage() — rather than accessing them as properties.Putting it all together
Here is a complete example combining page size, orientation, margins, a dynamic header, and a watermark:Next steps
Overview
See how page layout keys fit into the full document definition structure.
Content Nodes
Learn how to build the
content array with text, images, tables, lists, and columns.