
PDFKit
JavaScript library for generating PDF documents in Node and the browser.
- Stars
- 10.7k
- Forks
- 1.2k
- Licence
- MIT
- Language
- JavaScript
- Last update
- 4 days ago
- Type
- Library
What it is
PDFKit is a JavaScript library that creates PDF files from code, working in both Node.js and web browsers. You build a document by calling chainable functions to add text, images, vector shapes, tables, links and pages, then write the result to a file or HTTP response. It is aimed at generating multi-page, printable documents programmatically.
- Generate a multi-page document with embedded TrueType or OpenType fonts
- Add JPEG or PNG images scaled to fit a given box and aligned on the page
- Draw vector shapes with paths, gradients and transforms
- Add clickable links and highlight or underline annotations
- Produce a PDF in the browser and offer it as a downloadable Blob
Great for
- Node.js developers who need to generate PDFs such as invoices or reports from application data
- Developers building PDF output that must run in a browser without a server round trip
- Projects that need embedded fonts, JPEG/PNG images, links, or form fields in generated PDFs
- Teams that want a code-driven alternative to editing PDF templates by hand
Not ideal for
- People who only need to edit or fill existing PDFs, since the README describes creating documents rather than modifying them
- Users who want a no-code tool; the README shows only code examples
- Projects that need layout features the README lists as still coming, such as higher-level content layout APIs and pattern fills
How to get it
- 1
Install with a package manager
You'll need: Node.js (version not stated in README)
Install with npm
npm install pdfkitInstall with yarn
yarn add pdfkit - 2
Run it
- Install the package with npm or yarn
- Create a file that requires PDFDocument from 'pdfkit'
- Create a document, pipe it to a write stream, and add text or images
- Call doc.end() to finish the file
- 3
Get the most out of it
- Use the fit and align options on doc.image to size and position pictures precisely
- Embed your own TTF, OTF or WOFF fonts with doc.font for consistent branding
- Use the registerFile approach in browser builds to supply fonts and images without a file system
- Consult the programming guide and the demo folder in the repository for more examples
Downloads
Strengths
- Simple chainable API that the README says makes complex documents a few function calls
- Works in both Node and the browser, with a prebuilt standalone file and bundler guidance
- Broad feature set listed in the README, including encryption, outlines, AcroForms and accessibility support
Trade-offs
- Bundling for Node needs extra steps for standard fonts and PDF/A output, according to the README
- Browser helpers toBlob and toBytes are described as experimental and may change
- Layout is largely manual; the README says higher-level layout APIs are not yet available
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| pdfkit (this) | 10.7k | Library | beginner | 4 days ago | Node.js developers who need to generate PDFs such as invoices or reports from application data |
| jsPDF | 31.3k | Library | beginner | 5 days ago | Web developers who need to let users download a generated PDF from a page |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.