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

@pdfrx/engine

v0.27.0

Published

TypeScript client for the pdfrx pdfium WASM engine (worker protocol)

Readme

@pdfrx/engine

Typed TypeScript access to the PDFium WASM worker used by the pdfrx_web viewer packages. Use it directly for PDF rendering, text and link extraction, forms, annotations, page editing, or PDF encoding without a viewer UI. It supports browsers, Node.js, Bun, and Deno.

npm package · API reference · Detailed guide

Highlights

  • Worker-backed PDFium rendering keeps PDF processing off the calling thread.
  • Full-page and partial-region rendering supports high-resolution and tiled viewers, with cancellation before queued work starts.
  • Text extraction includes per-character geometry; links, outlines, forms, and annotations are exposed as typed data.
  • Annotation, form, outline, and page-arrangement edits can be encoded back to PDF, including non-destructive copy encoding.
  • Batched page-content authoring creates or inserts pages containing embedded text, raster images, and vector paths in one worker round trip.
  • Mixed-script FreeText preparation handles grapheme-safe wrapping, CJK language hints, and cross-runtime emoji appearances with configurable asset, renderer, and cache services.
  • HTTP range access can avoid downloading an entire remote PDF up front.
  • The same API runs in browsers, Node.js, Bun, and Deno.
  • Password callbacks, custom font registration, and raw PDF-object inspection cover advanced document workflows.

Install

npm install @pdfrx/engine

Minimal usage

import { PdfrxEngine } from '@pdfrx/engine';

const engine = new PdfrxEngine({
  wasmModulesUrl: 'https://cdn.jsdelivr.net/npm/@pdfrx/[email protected]/assets/',
});
const document = await engine.openUrl('/manual.pdf');
const page = document.pages[0];

if (page) {
  const image = await page.render({
    fullWidth: page.width * 2,
    fullHeight: page.height * 2,
  });
  if (image) canvasContext.putImageData(image.toImageData(), 0, 0);
}

await document.dispose();
engine.dispose();

In browsers, wasmModulesUrl must point to a directory containing pdfium_worker.js and pdfium.wasm. Copy both from node_modules/@pdfrx/engine/assets/ or serve the versioned CDN directory shown above. Non-browser runtimes discover the installed assets automatically.

API overview

Open a document

PdfrxEngine owns the worker and opens PdfDocument instances:

  • openUrl() opens a remote PDF, optionally using HTTP range access and a password callback.
  • openData() opens bytes supplied as an ArrayBuffer, typed array, or compatible binary source.

Create a document

The same PdfrxEngine creates new PdfDocument instances, then creates and arranges their pages:

Render and inspect pages

Documents expose their current page arrangement through PdfDocument.pages. Each PdfPage provides:

At document scope, loadOutline() reads bookmarks and loadFormFields() reads AcroForm controls and their values.

Edit document state

Document mutation events report page, annotation, and form changes with origin, transaction, and actor metadata, allowing applications to build persistence, history, or synchronization without polling.

Local fonts on Node, Bun, and Deno

Server runtimes can explicitly opt into local filesystem fonts:

const engine = new PdfrxEngine({
  localFonts: {
    systemDirectories: true,
    directories: ['./fonts'],
  },
  fontCache: {
    directory: './.cache/pdfrx-fonts',
    persistRegisteredFonts: true,
  },
});

PdfrxLocalFontsOptions controls OS and application font directories. The engine indexes internal font names and lazily loads missing faces. PdfrxFontCacheOptions caches that index and can optionally persist bytes passed to addFontData(). Persisting font bytes is disabled by default so the application can enforce its font licenses and data-handling policy. Deno requires matching filesystem permissions.

Encode and dispose

encodePdf() returns PDF bytes. Its copy mode materializes a temporary document so the live document and page proxies remain usable; compact mode rebuilds reachable page-level content with lower retention of document-level structures. The default live-document materialization is an explicit state boundary, so consult the guide before combining it with application Undo/Redo.

Dispose every document with PdfDocument.dispose() and dispose the engine when finished. In Node.js, the engine worker otherwise keeps the process alive.

Next steps

License

MIT