A JavaScript PDF generation library for Node and the browser.
open sourceMITself-hostablefree
PDFKit (foliojs/pdfkit, not Apple's PDFKit framework) builds PDFs programmatically through a canvas-like drawing API: vector paths, SVG path parsing, transforms and gradients, wrapped and aligned text, lists and tables, embedded and subset fonts (TrueType, OpenType, WOFF, WOFF2), JPEG and PNG images. It also supports annotations and links, AcroForms, outlines, encryption and access permissions, and tagged PDF / PDF/UA for accessibility. It runs in Node and in the browser via a bundler or a standalone build, and writes documents as a stream.
Problems it solves
- generate an invoice PDF from code in my Node backend, drawing text, lines and a logo myself
- I want full control over where every element goes on the page, not an HTML-to-PDF conversion
- stream a generated PDF straight into an HTTP response or S3 upload in Express
- draw charts and shapes into a PDF with a canvas-style API
- headless Chrome is too heavy for my serverless function, I just need to output simple documents
- build a printable report with wrapped paragraphs, bullet lists and custom fonts in JavaScript
- produce accessible tagged PDFs that pass PDF/UA checks from Node
- password-protect the PDFs my app generates and stop people printing or copying them
- create clickable links, bookmarks and a table of contents in a generated document
- make shipping labels or tickets as PDFs in the browser without a server
- embed WOFF2 web fonts and subset them so generated files stay small
Features
- Canvas-like vector graphics API with SVG path parsing, transforms and gradients
- Text wrapping, alignment, soft hyphens and bulleted lists
- Tables
- Font embedding and subsetting (TrueType, OpenType, WOFF, WOFF2, collections)
- JPEG and PNG images, including transparency
- Annotations: links, notes, highlights, underlines
- AcroForms
- Outlines (bookmarks)
- Encryption and access permissions
- Tagged PDF and PDF/UA accessibility
Capabilities
| Has official SDKs | plan not known |
|---|
Alternatives
The same job
These do what PDFKit does.
- Puppeteer JavaScript API for Chrome and Firefox
- jsPDF Client-side JavaScript PDF generation for everyone.
- pdfmake PDF document generation library for Node.js and browsers, written in pure JavaScript
- @react-pdf/renderer PDFs, made with React
- @cantoo/pdf-lib An actively maintained fork of pdf-lib: create and modify PDF documents in any JavaScript environment
- pdf-lib Create and modify PDF documents in any JavaScript environment.