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

@dicepdf/core

v0.1.0

Published

Portable, privacy-first PDF engine. The same operations that power dicepdf.com — runnable in Node, the browser, and AI agents. Your files never leave the machine.

Readme

@dicepdf/core

The portable PDF engine behind dicepdf.com. The same operations that power the website, packaged as pure functions you can call from Node, the browser, a CLI, or an AI agent.

One promise: your files never leave the machine. Every function reads bytes you already hold in memory and returns new bytes. There is no network path, no upload, no telemetry.

Install

npm install @dicepdf/core

Usage

import { readFile, writeFile } from 'node:fs/promises';
import { merge, splitByRanges } from '@dicepdf/core';
import { extractText } from '@dicepdf/core/extract';
import { renderToImages } from '@dicepdf/core/render';

// Merge
const a = await readFile('a.pdf');
const b = await readFile('b.pdf');
await writeFile('merged.pdf', await merge([a, b]));

// Extract text (great for feeding an LLM/agent)
const text = await extractText(await readFile('report.pdf'));

// Render pages to PNGs
const images = await renderToImages(await readFile('report.pdf'), { dpi: 150 });
for (const img of images) await writeFile(img.name, img.bytes);

// Split
const parts = await splitByRanges(await readFile('book.pdf'), [
  [1, 10],
  [11, 20],
]);
for (const part of parts) await writeFile(part.name, part.bytes);

Every operation accepts a Uint8Array or ArrayBuffer and (for PDF outputs) returns a Uint8Array.

Three entry points

| Import | Runs in | Pulls in | |--------|---------|----------| | @dicepdf/core | browser + Node | pdf-lib, fflate only — light & bundler-safe | | @dicepdf/core/extract | Node | pdfjs-dist (layout-aware text extraction) | | @dicepdf/core/render | Node | @napi-rs/canvas (optional) for rasterization |

The main entry has no node: imports, so it bundles cleanly into a browser or web-worker build. render needs the optional @napi-rs/canvas dependency (prebuilt — no native toolchain required).

API

| Function | Description | |----------|-------------| | merge(files) | Concatenate PDFs in order | | splitByRanges(file, ranges) / splitPages(file, pages) / splitEveryPage(file) | Split into multiple PDFs | | rotate(file, angle, pageIndices?) | Rotate 90/180/270° | | deletePages(file, pages) | Remove 1-based pages | | reorder(file, order) | Reorder via a page permutation | | crop(file, marginsMm) | Trim margins (millimeters) | | watermark(file, options) | Stamp a text watermark | | addPageNumbers(file, options) | Stamp page numbers | | stripMetadata(file, options?) | Remove Info/XMP/ID metadata | | compress(file) | Structural compression + metadata strip | | repair(file) | Best-effort reparse + rewrite | | imageToPdf(images, options?) | PNG/JPEG → PDF (one image per page) | | zip(entries) | Bundle named byte arrays into a ZIP | | getMetadata(file) | Page count, AcroForm, signature flag | | extractDocument / extractText / extractMarkdown | Layout-aware text extraction (/extract) | | renderToImages(file, options?) | Rasterize pages to PNG/JPEG (/render) | | compressAggressive(file, options?) | Rasterizing compression for scan-heavy PDFs (/render) |

Errors are typed: catch EncryptedPdfError and InvalidPdfError to branch on bad input.

License

MIT