explaingit

bpampuch/pdfmake

12,275JavaScriptAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A JavaScript library that generates PDF documents from a structured definition object, running in both web browsers and Node.js with support for tables, images, fonts, and page layouts.

Mindmap

mindmap
  root((pdfmake))
    Where it runs
      Web browser
      Node.js server
    Document Elements
      Paragraphs and text
      Tables and columns
      Images and lists
      Headers and footers
    Layout Options
      Page size and margins
      Portrait and landscape
      Multi-column flow
    Features
      Custom fonts
      Table of contents
      Page number references
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate a downloadable PDF invoice or report directly in the browser without any server round-trip

USE CASE 2

Build a Node.js service that creates formatted PDF documents like receipts, letters, or certificates

USE CASE 3

Add a print-to-PDF button to a web app that produces documents with tables, custom fonts, and page numbers

Tech stack

JavaScriptNode.jspdfkit

Getting it running

Difficulty · easy Time to first run · 30min
MIT license, use freely for any purpose, including commercial, as long as you keep the copyright notice.

In plain English

pdfmake is a JavaScript library that generates PDF documents. It works in two environments: inside a web browser, where it can create a PDF directly on the user's device, and on a server running Node.js, where it can generate PDFs as part of a back-end process. The library is driven by a document definition object. Instead of drawing on a page pixel by pixel, developers describe what a document should contain, including paragraphs, tables, images, lists, headers, and footers, and pdfmake handles all the layout calculations. It supports text alignment (left, right, centered, or justified), numbered and bulleted lists, tables with configurable column widths, column and row spans, automatically repeated table headers across page breaks, and a newspaper-style column layout where content flows from one column to the next. Other capabilities include embedded fonts, custom margins and page sizes, portrait or landscape orientation, a table of contents, multi-level nested structures, and document-level metadata such as author and subject fields. Page headers and footers can show static text or dynamic content that references the current page number and total page count. The library also provides helper functions to open a generated PDF in a new browser tab, print it directly, or trigger a file download. pdfmake is built on top of another library called pdfkit, which handles the lower-level PDF construction. An interactive playground is available online where developers can test document definitions in real time without installing anything. The library is released under the MIT license.

Copy-paste prompts

Prompt 1
Using pdfmake in my Node.js app, write me a document definition that creates an invoice with a header, an itemized table, a footer showing page numbers, and a total row
Prompt 2
Show me how to use pdfmake in the browser to generate a multi-page PDF with a table of contents and justified text columns
Prompt 3
How do I embed a custom font in a pdfmake document so all text uses it instead of the default font?
Prompt 4
Write a pdfmake document definition for a two-column newspaper-style layout with a title, body text, and a watermark
Open on GitHub → Explain another repo

← bpampuch on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.