Skip to main content

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.

pdfmake is a JavaScript library for generating PDF documents entirely in JavaScript — both in the browser and in Node.js. You describe your document as a plain JavaScript object and pdfmake renders it into a pixel-perfect PDF, handling text flow, tables, images, fonts, and more.

Quickstart

Create your first PDF in minutes with a working code example

Installation

Install pdfmake via npm or use the browser bundle

Document Definition

Learn the document definition object that drives everything

API Reference

Explore the full pdfmake instance and output document APIs

What you can build

pdfmake handles a wide range of document generation scenarios:

Rich Text

Fonts, colors, bold, italics, superscript, and inline styles

Tables

Complex tables with col/row spans, custom borders, and fill colors

Images & SVG

Embed JPEG, PNG, data URLs, and SVG graphics

Multi-column Layouts

Side-by-side columns and newspaper-style snaking layouts

Headers & Footers

Dynamic per-page headers, footers, backgrounds, and watermarks

Table of Contents

Auto-generated TOC with page number references

Custom Fonts

Embed custom TrueType fonts via the virtual file system

PDF Security

Password protection and permission restrictions

PDF/A Compliance

Generate archival-compliant PDF/A-1, PDF/A-2, and PDF/A-3 documents

Quick example

import pdfmake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';

pdfmake.vfs = pdfFonts.vfs;

const docDefinition = {
  content: [
    { text: 'Hello, pdfmake!', style: 'header' },
    'This is a PDF document generated entirely in JavaScript.',
    { text: 'Features at a glance:', margin: [0, 10, 0, 0] },
    {
      ul: [
        'Rich text and custom fonts',
        'Tables with complex layouts',
        'Images, SVGs, and QR codes',
        'Headers, footers, and watermarks'
      ]
    }
  ],
  styles: {
    header: { fontSize: 22, bold: true, margin: [0, 0, 0, 10] }
  }
};

pdfmake.createPdf(docDefinition).download('hello.pdf');
1

Install pdfmake

Add pdfmake to your project via npm or use the prebuilt browser bundle.
2

Define your document

Build a document definition object describing your content, styles, and layout.
3

Generate the PDF

Call createPdf() and use download(), open(), getBuffer(), or getBase64() to deliver the result.

Build docs developers (and LLMs) love