pdf-lib

TypeScript-first PDF library for creating and modifying PDF documents in both Node.js and browsers. Unlike jsPDF (create-only) or pdf-parse (read-only), pdf-lib can both create new PDFs and modify existing ones — adding pages, filling form fields, embedding images, merging documents, and reading/writing metadata. Used for document workflows requiring PDF manipulation.

Evaluated Mar 06, 2026 (0d ago) v1.17+
Homepage ↗ Repo ↗ Developer Tools pdf pdf-editing typescript browser node forms
⚙ Agent Friendliness
67
/ 100
Can an agent use this?
🔒 Security
88
/ 100
Is it safe for agents?
⚡ Reliability
82
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
85
Error Messages
80
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
90
Auth Strength
88
Scope Granularity
88
Dep. Hygiene
85
Secret Handling
88

Local processing — no network risk. PDF content injection risk if processing untrusted PDFs — validate and sandbox PDF inputs in production. MIT licensed with no telemetry.

⚡ Reliability

Uptime/SLA
85
Version Stability
82
Breaking Changes
82
Error Recovery
80
AF Security Reliability

Best When

You need to create or modify PDF documents programmatically — especially form filling, PDF merging, or adding content to existing PDFs.

Avoid When

You need HTML-to-PDF conversion, full-featured PDF text extraction, or legal digital signatures.

Use Cases

  • Fill PDF form fields programmatically in agent document processing workflows — employment forms, contracts, tax documents
  • Merge multiple PDFs into a single document in agent report generation pipelines
  • Add watermarks, stamps, or headers/footers to existing PDF documents in batch processing agents
  • Embed images and vector graphics into PDFs for certificate generation and branded document creation
  • Extract and manipulate PDF metadata (author, title, creation date) in document management agent workflows

Not For

  • HTML-to-PDF conversion — pdf-lib doesn't render HTML; use Puppeteer for that
  • PDF text extraction for analysis — use pdf-parse or PyMuPDF for text extraction; pdf-lib's text extraction is limited
  • Digital signature creation for legal compliance — PDF signing requires proper certificate authority chains beyond pdf-lib's scope

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No authentication — local library.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT-licensed open source library. Actively maintained.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • All operations are async (Promise-based) — must await PDFDocument.load(), embedFont(), save(); forgetting await produces empty or corrupt PDFs
  • Custom fonts must be embedded as ArrayBuffer — TTF/OTF font files must be read and embedded; system fonts are not available
  • PDF form filling requires knowing exact field names from the original PDF — use getForm().getFields() to discover field names before writing
  • Password-protected PDFs require the password at load time — pdf-lib can load encrypted PDFs but most encryption schemes require explicit password parameter
  • PDF modification of PDFs with complex features (JavaScript, 3D, multimedia) may strip those features on save — pdf-lib is not a full PDF-compliant editor
  • Large PDFs (100+ pages) can consume significant memory during processing — consider streaming approaches or page-by-page processing for large documents

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for pdf-lib.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered