npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pdf-lite

v1.5.0

Published

A low-level, zero-dependency, type-safe PDF library for Node.js and the browser

Downloads

1,438

Readme

Examples | Documentation

pdf-lite

A low-level, minimal-dependency, type-safe PDF library that works in the browser and Node.js.

Note: This library is actively developed and may not support all PDF features yet. However, it is designed to be extensible and can be improved over time.

PRs and issues are welcome!

npm version License: MIT

Features

  • Type-safe: Built with TypeScript, ensuring type safety and reducing runtime errors.
  • Browser and Node.js support: Works seamlessly in both environments, allowing for versatile usage.
  • Low-level API: Provides a low-level API for advanced users who want to manipulate PDF files directly, as well as a higher-level API for easier usage.
  • Minimal dependencies: A small number external libraries are required, making it lightweight and easy to integrate.

Installation

npm install pdf-lite
yarn add pdf-lite
pnpm add pdf-lite

Usage

The library provides both low-level and high-level APIs for working with PDF documents. See PDF Support for a list of supported features.

Reading a PDF

import { PdfReader } from 'pdf-lite/pdf/pdf-reader'
import { readFile } from 'fs/promises'

const pdfBytes = await readFile('document.pdf')
const doc = await PdfReader.fromBytes([pdfBytes])

Creating a PDF from Scratch

import { PdfDocument } from 'pdf-lite/pdf/pdf-document'
import { PdfDictionary } from 'pdf-lite/core/objects/pdf-dictionary'
import { PdfIndirectObject } from 'pdf-lite/core/objects/pdf-indirect-object'
import { PdfStream } from 'pdf-lite/core/objects/pdf-stream'
import { PdfName } from 'pdf-lite/core/objects/pdf-name'
import { PdfArray } from 'pdf-lite/core/objects/pdf-array'
import { PdfNumber } from 'pdf-lite/core/objects/pdf-number'

// Create the document
const document = new PdfDocument()

// Create content stream
const contentStream = new PdfIndirectObject({
    content: new PdfStream({
        header: new PdfDictionary(),
        original: 'BT /F1 24 Tf 100 700 Td (Hello, PDF-Lite!) Tj ET',
    }),
})

// Create and commit objects
document.commit(contentStream)
// ... create pages, catalog, etc.

// Output the PDF
console.log(document.toString())

Working with Encryption

import { PdfDocument } from 'pdf-lite/pdf/pdf-document'
import { PdfV2SecurityHandler } from 'pdf-lite/security/handlers/v2'

const document = new PdfDocument()
// ... build your PDF structure

// Set up encryption
document.securityHandler = new PdfV2SecurityHandler({
    password: 'user-password',
    documentId: 'unique-doc-id',
    encryptMetadata: true,
})

// Encrypt the document
await document.encrypt()

console.log(document.toString())

Signing PDFs

import {
    PdfAdbePkcs7DetachedSignatureObject,
    PdfEtsiCadesDetachedSignatureObject,
} from 'pdf-lite'

// See examples directory for complete signing implementations

For more detailed examples, see the EXAMPLES.md file and the examples/ directory.

PDF Support

Low-level PDF constructs

Provides access to low-level PDF constructs, allowing for advanced manipulation and customization of PDF documents.

  • [x] PDF numbers
  • [x] PDF strings
  • [x] PDF arrays
  • [x] PDF dictionaries
  • [x] PDF streams
  • [x] PDF null
  • [x] PDF booleans
  • [x] PDF object references
  • [x] PDF name objects
  • [x] PDF indirect objects
  • [x] PDF comments
  • [x] PDF trailer
  • [x] PDF object streams
  • [x] PDF xref streams
  • [x] PDF xref tables

Encryption

Supports encrypting and decrypting PDF files using standard algorithms, ensuring document security. Implements a password recovery feature for encrypted PDFs, allowing users to regain access to their documents.

Encryption algorithms supported:

  • [x] RC4-40
  • [x] RC4-128
  • [x] AES-128
  • [x] AES-256

Encryption methods:

  • [x] Password-based encryption
  • [x] Certificate-based encryption (public key)

Compression

Handles various compression algorithms, including Flate, LZW, and RunLength for efficient file size management. Note: image compression such as JPEG is not supported.

Compression algorithms supported:

  • [x] Flate
  • [x] LZW
  • [x] ASCII85
  • [x] ASCIIHex
  • [x] RunLength

Signing

PDF Signatures are powered by the pki-lite library.

Provides support for digitally signing PDF documents, ensuring authenticity and integrity. All signing functionality is integrated into the main pdf-lite package.

Signing algorithms supported:

  • [x] RSA
  • [x] ECDSA

Signature types supported:

  • [x] adbe.pkcs7.detached
  • [x] adbe.pkcs7.sha1
  • [x] adbe.x509.rsa_sha1
  • [x] ETSI.CAdES.detached
  • [x] ETSI.RFC3161

LTV support/Revocation Info/Document Security Store (DSS):

Long-Term Validation (LTV) support ensures that digital signatures remain valid over time, even after the signing certificate has expired. To enable this, the Document Security Store (DSS) is used to store revocation information and other metadata related to the signature.

  • [x] DSS (Document Security Store)
  • [x] CRL (Certificate Revocation List)
  • [x] OCSP (Online Certificate Status Protocol)

Other features:

  • [x] Timestamping
  • [x] Verification of existing signatures

AcroForm filling

Supports filling out AcroForm forms within PDF documents, allowing for dynamic content generation and user interaction.

  • [x] Text fields
  • [x] Checkboxes
  • [x] Radio buttons
  • [x] Dropdowns

XFA Forms

You can read/write XFA XML data from PDFs, but rendering and filling XFA forms is not supported.

  • [x] Read XFA XML
  • [x] Write XFA XML

Future Plans

  • Writing Linearized PDF: Writing linearized PDFs for faster web viewing, improving user experience when accessing documents online.

Development

This project uses pnpm for package management.

Setup

pnpm install

Building

pnpm compile

Testing

# Run all tests
pnpm test

# Run unit tests only
pnpm test:unit

# Run acceptance tests
pnpm test:acceptance

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

API Reference

See the documentation folder or the document site for a complete API reference.

License

MIT License - see LICENSE for details.