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

pdfglyph-client

v1.0.1

Published

Official Node.js client for the PDFGlyph API — render HTML and CSS to pixel-perfect PDFs with one API call.

Readme

pdfglyph-client

Official Node.js client for the PDFGlyph API — render HTML and CSS to pixel-perfect PDFs, or full-page screenshots, with one API call.

Ships both ESM and CommonJS builds with TypeScript types. No runtime dependencies. Requires Node 20 or newer (it uses the global fetch).

Installation

npm install pdfglyph-client

Getting an API key

This client talks to a hosted service and needs an account. The free tier is 100 renders a month with no card: sign up at pdfglyph.com and create a key in the dashboard. Keys are prefixed pk_test_ or pk_live_.

Quick start

import { PDFGlyph } from "pdfglyph-client";
import fs from "node:fs";

const client = new PDFGlyph(process.env.PDFGLYPH_API_KEY);

// Synchronous render — PDF bytes come straight back
const { pdf, pageCount } = await client.renderSync({
  html: "<h1>Hello World</h1>",
});
fs.writeFileSync("output.pdf", pdf);
console.log(`Generated ${pageCount} page PDF`);

// Async render — submit a job, poll, download
const job = await client.render({ html: "<h1>Hello World</h1>" });
await client.waitForCompletion(job.jobId);
const bytes = await client.downloadPdf(job.jobId);

CommonJS works too:

const { PDFGlyph } = require("pdfglyph-client");

Screenshots

Set format to png or jpeg and the same endpoint returns images instead of a PDF. Pages are 1-based and match the order of screenshotUrls.

const job = await client.render({ html: "<h1>Hi</h1>" }, { format: "png" });
await client.waitForCompletion(job.jobId);

const { image, contentType } = await client.downloadScreenshot(job.jobId, 1);
fs.writeFileSync("page-1.png", image);

Webhooks

Pass webhookUrl when submitting a job and PDFGlyph will POST to it on completion, signed with HMAC-SHA256 in the X-PDFGlyph-Signature header. Verify against the raw request body — parsing and re-serializing the JSON first will change the bytes and break the signature.

const isValid = PDFGlyph.verifyWebhookSignature(
  rawBody,
  req.headers["x-pdfglyph-signature"],
  process.env.PDFGLYPH_WEBHOOK_SECRET,
);

Errors

Any non-2xx response throws a PDFGlyphError carrying the server's message and the HTTP status:

import { PDFGlyphError } from "pdfglyph-client";

try {
  await client.renderSync({ html });
} catch (err) {
  if (err instanceof PDFGlyphError && err.statusCode === 402) {
    // monthly quota exhausted
  }
  throw err;
}

API reference

new PDFGlyph(apiKey, options?)

  • apiKey — your API key (pk_live_* or pk_test_*)
  • options.baseUrl — override the API base URL (default https://pdfglyph.com)

Methods

| Method | Description | | --- | --- | | render(input, options?) | Submit an async render job | | renderSync(input, options?) | Render now; resolves to { pdf, pageCount, fileSize, renderTimeMs, totalTimeMs } | | getJob(jobId) | Fetch job status | | cancelJob(jobId) | Cancel a queued or processing job | | downloadPdf(jobId) | Download the finished PDF as a Buffer | | downloadScreenshot(jobId, page?) | Download one screenshot page (1-based); resolves to { image, contentType } | | waitForCompletion(jobId, options?) | Poll until terminal; options.timeout (ms, default 60000) and options.interval (ms, default 1000) |

input accepts html, css, and url. options accepts format, landscape, margins, headerTemplate, footerTemplate, pageRanges, printBackground, and webhookUrl.

Static methods

  • PDFGlyph.verifyWebhookSignature(payload, signature, secret) — constant-time HMAC check, returns a boolean

License

MIT