TheDocumentation 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.
content key of your document definition is where your PDF actually lives. It holds an ordered array of content nodes — objects (or plain strings) that pdfmake lays out from top to bottom, wrapping across pages as needed. Every visible element in your document — a paragraph, a table, an image, a list — is represented as a node in this array.
The content array
At its simplest, content is a flat JavaScript array. Each entry is either a plain string (treated as a paragraph) or a node object that carries both content and rendering instructions:
Plain strings vs text objects
The most common node type is text. pdfmake accepts both a raw string and a full text object:text node can also hold an array of inline runs, letting you mix styles within a single paragraph:
Common node properties
These properties are available on virtually every node type, regardless of whether it is a text block, a list, a table, or a columns layout.style
A named style string or array of style strings to apply. Styles are defined in the top-level
styles map. Multiple styles are applied left to right; later styles win conflicts.margin
Extra space outside the node. Accepts a single number (all sides),
[horizontal, vertical], or [left, top, right, bottom].alignment
Text alignment:
'left' (default), 'center', 'right', or 'justify'.pageBreak
Force a page break relative to this node. Use
'before' to start a new page before the node, or 'after' to break after it.id
A string identifier for the node. Used as an anchor target for internal cross-references and table-of-contents entries.
opacity
A number between
0 (invisible) and 1 (fully opaque). Applies to text and other visual nodes.Margins are not inherited by child nodes. A
margin on a stack applies to the stack as a whole; the nodes inside the stack do not automatically pick it up.Node types overview
pdfmake’s layout engine recognises the following node types, detected by which key is present on the node object.text — Paragraphs and inline runs
The most basic node. Renders one or more lines of text. The text value can be a string or an array of inline run objects.
ul — Unordered list
Renders a bulleted list. Items can be strings or nested node objects.
ol — Ordered list
Renders a numbered list. Supports start, reversed, and per-item counter overrides.
table — Data tables
Renders a grid of cells. The table object requires a body array of row arrays, and optionally widths, heights, and headerRows.
image — Raster images
Embeds a JPEG or PNG image. Reference images by a key defined in the top-level images map, or supply a URL or base64 data URI directly. Use width, height, or fit to control sizing.
svg — Vector graphics
Embeds an inline SVG string. Both width and height must be defined.
canvas — Vector shapes
Low-level drawing API for lines, rectangles, ellipses, and polylines using pdfmake’s own canvas primitives.
columns — Side-by-side layout
Splits the available width into two or more columns. Each column is itself a content node (or an array of nodes). Column widths can be fixed numbers, '*' (star / equal share), or 'auto' (fit content).
stack — Vertical group
Groups multiple nodes into a single logical block. Useful for applying a shared style or margin to a set of nodes, or for nesting content inside columns.
toc — Table of contents
Generates an automatic table of contents from all nodes that carry tocItem: true. The title property is itself a content node.
tocItem: true:
qr — QR codes
Renders a QR code for the given string value. Control the size with fit.
attachment — File attachments
Embeds a file attachment into the PDF. The attachment node does not render visible content on the page but is included in the document. Use width and height to control the invisible placeholder size (defaults: 7 × 18 pt).
Nesting content
Content nodes can contain other content nodes. Columns hold arrays of nodes; stacks hold arrays of nodes; table cells hold nodes. This composability lets you build complex layouts from simple primitives.The stack type for grouping
A stack node wraps multiple child nodes and renders them vertically. Its main use case is applying a shared style or margin to a group without affecting the children individually:
fontSize from the header style is inherited by both children, but any margin set on the header style applies only to the outer stack node.
Page break control
Static page breaks
AddpageBreak: 'before' to start a new page immediately before a node, or pageBreak: 'after' to break after it:
Dynamic page breaks with pageBreakBefore
For more control, define a pageBreakBefore callback at the document level. pdfmake calls it before placing each node and passes the node’s info plus an object with three lazy getter functions. Return true to insert a page break before that node:
| Parameter | Description |
|---|---|
currentNode | The node info object about to be placed |
getFollowingNodesOnPage() | Lazy getter — returns nodes already committed to the current page after currentNode |
getNodesOnNextPage() | Lazy getter — returns nodes that will appear on the next page |
getPreviousNodesOnPage() | Lazy getter — returns nodes already placed on the current page before currentNode |
The three node-context helpers are getter functions, not plain arrays. Call them as
getFollowingNodesOnPage() rather than accessing them as properties.Styling properties on nodes
Beyondstyle, you can set any supported typography or layout property directly on a node. These inline overrides take priority over named styles and defaultStyle:
Next steps
Overview
Return to the document definition overview to see how
content fits alongside styles, page layout, and security settings.Page Layout
Configure page size, orientation, margins, and per-section settings.