LibPDF

Introduction

A modern PDF library for TypeScript - parsing, generation, forms, encryption, and digital signatures.

LibPDF

A modern PDF library for TypeScript focused on both parsing and generation.

Beta Software

LibPDF is under active development. We don't have plans to introduce breaking changes, but we're still experimenting to make sure this becomes the best PDF library for TypeScript. APIs may evolve as we refine the developer experience.

Why?

The JavaScript ecosystem's PDF landscape is fragmented:

  • pdf.js (Mozilla) - excellent parsing/rendering, but focused on browser viewing, not manipulation
  • pdf-lib - great for generation and basic manipulation, but parsing is limited
  • pdfkit - generation only, no parsing

LibPDF fills that gap with a single, comprehensive library that handles parsing, generation, forms, encryption, and digital signatures.

Quick Example

import { PDF } from "@libpdf/core";

const pdf = await PDF.load(bytes);
console.log(`${pdf.getPageCount()} pages`);

const page = await pdf.getPage(0);
const text = await page.extractText();

Features

FeatureStatusNotes
PDF 1.0–1.7FullRead and write
PDF 2.0ReadWrite planned
Encrypted PDFsFullRC4, AES-128, AES-256
AcroFormsFullRead, fill, flatten
Digital SignaturesSignPAdES B-B through B-LTA
Text ExtractionFullWith positions and search
Font EmbeddingFullTTF/OTF with subsetting
Incremental SavesFullPreserves existing signatures

Installation

npm install @libpdf/core

Works with Node.js 18+, Bun, and browsers. No polyfills required.

What's Next?

Known Limitations

  • Predefined CJK CMaps: Only Identity-H and Identity-V CMaps are supported. Legacy CJK PDFs using predefined CMaps without ToUnicode maps may not extract text correctly.
  • Signature Verification: Signing works; verification is not yet implemented.
  • XFA Forms: Data extraction only; XFA rendering is not supported.
  • Annotations: Read/write/flatten support is planned but not yet implemented.

On this page