pdf-lib

Create and modify PDF documents in any JavaScript environment, from Node to the browser

Library
npm
v1.17.1
8,589stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
50/100Fair
Development Activity0
Maintenance32
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture78
Code Quality72
Innovation75
Learning Curve82

pdf-lib is a pure JavaScript/TypeScript library for creating and modifying PDF documents without relying on native dependencies or a headless browser. Unlike most JavaScript PDF tools that can only generate new documents from scratch, pdf-lib can load and edit existing PDFs — adding pages, filling and flattening forms, embedding images and fonts, and drawing text or vector graphics directly onto pages.

Because it has zero native bindings, pdf-lib runs identically in Node.js, browsers, Deno, and React Native, making it a common choice for client-side PDF generation and for serverless environments where installing tools like wkhtmltopdf or a headless Chrome instance is impractical.

What You Get

  • A PDFDocument API to create new PDFs or load and modify existing ones
  • Full AcroForm support: create, fill, and flatten form fields (text, checkboxes, radio groups, dropdowns, option lists)
  • Page manipulation: add, insert, remove, and copy pages between documents
  • Drawing primitives for text, images (PNG/JPEG), vector graphics, and SVG paths
  • Standard and custom font embedding with Unicode (UTF-8/UTF-16) support
  • Document metadata and viewer-preference reading/writing, plus attachment embedding
  • Runs with zero native dependencies in Node, browsers, Deno, and React Native

Common Use Cases

  • Filling and flattening PDF forms server-side for contracts, applications, or tax documents
  • Generating invoices, receipts, or reports entirely in the browser without a backend
  • Merging or splitting existing PDFs by copying pages between documents
  • Watermarking or stamping existing PDFs with text, images, or SVG graphics
  • Programmatically embedding attachments or updating document metadata in a document pipeline

Under The Hood

Architecture — pdf-lib is organized around a layered API in src/: api/ exposes the high-level, user-facing classes (PDFDocument, PDFPage, PDFForm and field types under api/form/, PDFFont, PDFImage), while core/ implements the low-level PDF object model (dictionaries, streams, xref tables, the document parser/writer) that the API layer manipulates. PDFDocument acts as the central mutable in-memory representation: PDFDocument.load() parses an existing file’s object graph into this model, create() builds one from scratch, and save() serializes it back to bytes — the same representation drives editing and creation through one code path.

Tech Stack — Written in TypeScript, built with Rollup into CJS, ESM, and UMD bundles (plus a downlevel-dts pass for older TypeScript consumers) so it can be imported directly in Node, bundled for the browser, or loaded via <script> tag. It has no runtime dependencies on native binaries or headless browsers — the entire PDF object model and rendering-primitive logic is implemented in pure JS/TS, which is what allows identical behavior across Node, browsers, Deno, and React Native.

Code Quality — Tests live under tests/ as Jest specs (tests/api/*.spec.ts, plus dedicated suites for forms and text handling) run via jest --config jest.json --runInBand, with fixture PDFs used to assert against known-good outputs. The codebase enforces tslint and prettier in its lint scripts, and TypeScript’s tsc --noEmit is run as a standalone typecheck step. The project has been effectively feature-complete since ~2021, with recent commit activity dropping to near zero, so open issues around edge-case encodings/newer PDF spec features can persist longer than in an actively maintained project.

API Design — The PDFDocument/PDFPage/PDFForm object-oriented surface reads close to a document-editing DSL (pdfDoc.addPage(), page.drawText(...), form.getTextField(...).setText(...)), keeping common operations to a handful of chained calls. Every public method and class is documented with TSDoc comments that ship in the published types, and the README’s example-driven structure (create/modify/fill/flatten/copy, each with a live JSFiddle demo) makes the learning curve shallow for common tasks, though deeper PDF-spec concepts (encryption, low-level object references) require reading core/ directly.

Used by 14 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
99%
AGPL 3.0

Cherry Studio

AI Assistants

50,753

All-in-one AI desktop client with 300+ assistants and multi-model support

View details
88
Repo Health
84
Technical
71
Dependency
Built with
TypeScript99%
Updated today
TypeScript
99%
AGPL 3.0

fountain-ink

Blogging

64

A self-hostable, decentralized blogging platform built on Lens Protocol — own your content, audience, and distribution forever.

View details
26
Repo Health
66
Technical
69
Dependency
Built with
TypeScript99%
Updated 6 months ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
76%
Other

Joplin

Note Taking

56,003

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
62
Dependency
Built with
TypeScript76%
JavaScript15%
Updated yesterday
TypeScript
97%
Other

Kibana

Analytics · Monitoring

21,251

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
68
Dependency
Built with
TypeScript97%
Updated today
TypeScript
72%
Apache 2.0

Litlyx

Analytics

1,741

Cookie-free, AI-powered web analytics you can self-host in 30 seconds with Docker.

View details
44
Repo Health
51
Technical
74
Dependency
Built with
TypeScript72%
Vue26%
Updated 8 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search