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

@mescius/ds-pdf

v9.1.0

Published

Universal Wasm-powered PDF and imaging SDK for browser and Node.js

Readme

@mescius/ds-pdf

Document Solutions for PDF JS

Document Solutions for PDF JS (DsPdfJS) is a powerful PDF library for JavaScript and TypeScript that provides a rich set of APIs for fast, memory-efficient PDF and image processing in modern web and server-side environments.

Powered by WebAssembly (Wasm), DsPdfJS runs in browsers and JavaScript runtimes such as Node.js, Deno, and Bun. Its core object model follows the PDF specification, providing programmatic access to PDF elements such as document properties, pages, fonts, annotations, forms, and more.

DsPdfJS also includes high-level APIs for creating PDF documents with complex layouts including formatted text, graphics, images, forms, and advanced document workflows.

Features include:

  • Programmatically create, load, modify, save, or inspect PDF documents
  • Support for modern PDF standards
  • Export PDF pages to raster or vector image formats
  • Merge or split PDF documents
  • Draw text, shapes, paths, and images with high-level graphics APIs
  • Powerful text formatting and layout engine with wrapping, alignment, spacing, tabs, RTL text (including Kashida), and vertical writing
  • Advanced font handling with embedding and subsetting support
  • Add raster or vector images including PNG, JPEG, SVG, and SVGZ
  • Create, edit, fill, or flatten AcroForm PDF forms
  • Work with annotations, links, text markup, and rich media
  • Find and replace text with configurable search options and exact match positions
  • Programmatically create and apply redactions to permanently remove sensitive content
  • Encryption and security APIs
  • Image processing APIs for resizing, transforming, filtering, drawing, and bitmap generation
  • Designed for efficient memory usage through explicit Wasm object lifecycle management
  • TypeScript-ready with modern module support

Compatibility:

DsPdfJS is compatible with:

  • Environments:
    • Modern browsers
    • Node.js, Deno, Bun, other Node‑compatible runtimes
  • Module formats:
    • ES Modules
    • CommonJS
    • UMD
  • TypeScript (type definitions are included)

Installation:

npm install @mescius/ds-pdf

Getting Started:

1. Set the WebAssembly (Wasm) URL

DsPdfJS uses a WebAssembly module. You must point DsPdfConfig.wasmUrl to the shipped .wasm file:

import { DsPdfConfig } from "@mescius/ds-pdf";
DsPdfConfig.wasmUrl = "/node\_modules/@mescius/ds-pdf/assets/DsPdf.wasm";

2. (Optional) Apply a License Key

// await DsPdfConfig.setLicenseKey("YOUR\_LICENSE\_KEY");

3. Connect to DsPdfJS

import { connectDsPdf } from "@mescius/ds-pdf";
const connected = await connectDsPdf();
if (!connected) throw new Error("Failed to initialize DsPdfJS.");

Usage:

Browser (ES Modules)

import { DsPdfConfig, connectDsPdf, PdfDocument, pushObjectManager, popObjectManager
} from "@mescius/ds-pdf";

DsPdfConfig.wasmUrl = "/node_modules/@mescius/ds-pdf/assets/DsPdf.wasm";
// await DsPdfConfig.setLicenseKey("...");

if (!(await connectDsPdf())) throw new Error("Failed to initialize DsPdfJS.");

pushObjectManager();
try {
  const doc = new PdfDocument();
  const page = doc.pages.addNew();
  const ctx = page.context;

  ctx.drawText({ text: "Hello, World!", fontSize: 20 }, 72, 72);

  const pdfData = doc.savePdf();
  // pdfData is a Uint8Array (or equivalent binary buffer)
  return pdfData;
} finally {
  popObjectManager();
}

Browser (Pure JavaScript / UMD)

Include the UMD bundle directly:

<script src="node_modules/@mescius/ds-pdf/umd/ds-pdf.js"></script>
<script>
async function createDocument() {
  // UMD bundle exposes global 'DocSol'
  DocSol.DsPdfConfig.wasmUrl = "/node_modules/@mescius/ds-pdf/assets/DsPdf.wasm";
  // await DocSol.DsPdfConfig.setLicenseKey("...");

  const connected = await DocSol.connectDsPdf();
  if (!connected) throw new Error("Failed to initialize DsPdfJS.");

  // Use an ObjectManager to control native/Wasm-backed object lifetimes:
  const om = new DocSol.ObjectManager();
  try {
    const doc = new DocSol.PdfDocument(om);
    const page = doc.pages.addNew();
    const ctx = page.context;

    ctx.drawText({ text: "Hello, World!", fontSize: 20 }, 72, 72);

    return doc.savePdf();
  } finally {
    om.dispose();
  }
}

createDocument()
  .then(pdfData => console.log("PDF created:", pdfData))
  .catch(err => console.error(err));
</script>

Node.js (CommonJS)

const { DsPdfConfig, connectDsPdf, PdfDocument, ObjectManager } = require("@mescius/ds-pdf");

// Example: set to the package Wasm (adjust to your environment/pathing)
DsPdfConfig.wasmUrl = "./node_modules/@mescius/ds-pdf/assets/DsPdf.wasm";
// await DsPdfConfig.setLicenseKey("...");

(async () => {
  if (!(await connectDsPdf())) throw new Error("Failed to initialize DsPdfJS.");

  const om = new ObjectManager();
  try {
    const doc = new PdfDocument(om);
    const page = doc.pages.addNew();
    const ctx = page.context;

    ctx.drawText({ text: "Hello, World!", fontSize: 20 }, 72, 72);

    const pdfData = doc.savePdf();
    return pdfData;
  } finally {
    om.dispose();
  }
})();

Memory Management: ObjectManager

Many objects are backed by Wasm memory. Use one of these patterns to control memory usage:

  • Push/pop: pushObjectManager(); ... popObjectManager();
  • Explicit: const om = new ObjectManager(); ... om.dispose();
  • Decorator: @withObjectManager async pdfSample1() { ... }

This makes sure that intermediate objects are released when no longer needed.


Notes:

  • Coordinate units in PDF drawing contexts are “page units” (points) by default (72 units per inch), but can be changed as needed.
  • Coordinate units in image drawing contexts are pixels (96 units per inch).

Resources:


Other Document Solutions Products:

Document Solutions JavaScript Viewers:


License:

A commercial license is required for production use.

Each purchase includes one year of updates and support. Please contact MESCIUS Sales ([email protected]) for pricing, trial keys, and licensing options.