pdfmake is an open-source JavaScript library that turns a plain JavaScript object — called a document definition — into a fully formatted PDF. It runs entirely in the browser or in a Node.js process, with no native binaries, no server round-trips, and no external tools required. Whether you’re generating invoices, reports, or certificates, the same API works everywhere.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.
How it works
The central concept in pdfmake is the document definition object (docDefinition). You describe what the document should contain — text, tables, images, headers, footers, page margins — as a plain JavaScript object, then pass it to createPdf(). pdfmake’s layout engine handles line wrapping, page breaking, font embedding, and rendering, and hands you back a document object you can download, open, print, or stream to disk.
createPdf() → output document → deliver.
Browser vs Node.js
pdfmake ships two entry points that share the same declarative API but deliver the output differently.| Environment | Import | Delivery methods |
|---|---|---|
| Browser | pdfmake.min.js bundle | download(), open(), print(), getBlob(), getBase64(), getDataUrl() |
| Node.js | require('pdfmake') | write(filename), getBuffer(), getBase64(), getStream() |
pdfmake.addFonts() before calling createPdf().
Key features
pdfmake supports a rich set of layout and typography primitives out of the box:- Automatic line-wrapping and page-breaking
- Text alignment: left, right, center, and justified
- Ordered (
ol) and unordered (ul) lists, with nesting and custom marker types - Tables with auto/fixed/star-sized columns,
colSpan,rowSpan, and repeated headers - Columns and snaking (newspaper-style) layouts
- Images (JPEG/PNG) and SVG vector graphics
- Convenient named styles and style inheritance
- Static and dynamic page headers and footers with access to current page number and total
- Background layers and watermarks
- Document sections, custom page breaks, and page dimensions/orientations
- Font embedding — including custom typefaces via the virtual file system
- Table of contents
- PDF metadata (author, subject, keywords)
Explore the features
Text Styling
Fonts, sizes, colors, alignment, inline rich text, and named style inheritance.
Tables
Column widths, row/col spans, repeated headers, custom layouts, and cell styling.
Images & SVG
Embed raster images and SVG graphics with fit, cover, and positioning options.
Custom Fonts
Embed any TrueType or OpenType font using the virtual file system.
Headers & Footers
Static or dynamic content with access to current page number and total page count.
PDF Security
Password protection, permissions, and encryption for generated documents.
The virtual file system (vfs)
pdfmake uses an in-memory virtual file system to store binary assets — primarily font files — so they are available in environments (like the browser) that have no real file system access. When you includevfs_fonts.js in the browser, it populates this virtual FS with the Roboto font family. In Node.js, fonts are referenced by their actual file system paths, so no vfs setup is needed for the built-in Roboto font. For custom fonts in the browser you use pdfmake.addVirtualFileSystem() or pdfmake.addFontContainer() to register the base64-encoded font data.