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

pdfgate

v1.0.4

Published

PDFGate API client

Readme

PDFGate Node SDK

Official Node.js client for the PDFGate API.

PDFGate lets you generate, process, and secure PDFs via a simple API:

  • HTML or URL to PDF
  • Fillable forms
  • Flatten, compress, watermark, protect PDFs
  • Extract PDF form data

📘 Documentation: https://pdfgate.com/documentation
🔑 Dashboard & API keys: https://dashboard.pdfgate.com


Installation

npm install pdfgate
# or
yarn add pdfgate

Sandbox / Production client

import PdfGate from 'pdfgate';

const client = new PdfGate('live_xxxxxx'); // Use your production API key
// const client = new PdfGate('test_xxxxxx'); // Use your sandbox API key

Quick start

import PdfGate from 'pdfgate';
import fs from 'fs';

const client = new PdfGate(process.env.PDFGATE_API_KEY);

const pdf = await client.generatePdf({
  url: 'https://example.com',
});

fs.writeFileSync('out.pdf', pdf);

Usage with CommonJS

const PdfGate = require('pdfgate');

const client = new PdfGate(process.env.PDFGATE_API_KEY);

Buffer vs JSON responses

Most endpoints return PDF bytes (Buffer) by default. However, if you want a JSON document response (with optional fileUrl), use the following:

const doc = await client.generatePdf({
  url: 'https://example.com',
  jsonResponse: true,
  preSignedUrlExpiresIn: 3600, // Use this to return fileUrl
});

console.log(doc);

Examples

Generate PDF from URL

const pdf = await client.generatePdf({
  url: 'https://example.com/',
  scale: 1.3,
});

fs.writeFileSync('out.pdf', pdf);

Generate PDF from HTML with fillable fields

const pdf = await client.generatePdf({
  html: '<div><p>Hello World</p> <div><input type="text" name="textfield"/></div></div>',
  enableFormFields: true,
});

fs.writeFileSync('out.pdf', pdf);

Get document metadata

const doc = await client.getDocument({
  id: 'DOCUMENT_ID',
  preSignedUrlExpiresIn: 86400,
});

console.log(doc);

Download a stored PDF file

const file = await client.getFile({
  documentId: 'DOCUMENT_ID',
});

fs.writeFileSync('out.pdf', file);

Flatten a PDF (make form fields non-editable)

import fs from 'fs';

const input = fs.readFileSync('toflatten.pdf');

const out = await client.flattenPdf({
  file: { name: 'toflatten.pdf', data: Buffer.from(input) },
});

fs.writeFileSync('out.pdf', out);

Compress a PDF

const doc = await client.compressPdf({
  documentId: 'DOCUMENT_ID',
  linearize: false,
  jsonResponse: true,
});

console.log(doc);

Watermark a PDF

import fs from 'fs';

const font = fs.readFileSync('font.ttf');

const doc = await client.watermarkPdf({
  documentId: 'DOCUMENT_ID',
  type: 'text',
  fontFile: { name: 'font.ttf', data: Buffer.from(font) }, // use your own font file
  text: 'My watermark',
  rotate: 30,
  opacity: 0.3,
});

fs.writeFileSync('out.pdf', doc);

Protect (encrypt) a PDF

import fs from 'fs';

const input = fs.readFileSync('input.pdf');

const doc = await client.protectPdf({
  file: { name: 'input.pdf', data: Buffer.from(input) },
  algorithm: 'AES256',
  userPassword: 'user',
  ownerPassword: 'owner',
  disableEditing: true,
  disableCopy: true,
  disablePrint: true,
  encryptMetadata: true,
});

fs.writeFileSync('protected.pdf', doc);

Extract PDF form data

const data = await client.extractPdfFormData({
  documentId: 'DOCUMENT_ID',
});

console.log(data);