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

@smontero/pdf-utils

v1.0.2

Published

A lightweight Node.js utility and library for identifying and filling form fields in PDF documents, powered by [pdf-lib](https://pdf-lib.js.org/).

Readme

@smontero/pdf-utils

A lightweight Node.js utility and library for identifying and filling form fields in PDF documents, powered by pdf-lib.

Features

  • Field Extraction: Identify all form fields in a PDF, including their names, types, and possible values (for dropdowns, radio groups, etc.).
  • Form Filling: Programmatically populate PDF forms using a simple JSON mapping.
  • Support for Multiple Field Types: Works with Text Fields, Checkboxes, Radio Groups, Dropdowns, and Option Lists.
  • Form Flattening: Optionally flatten forms after filling to make them non-editable.

Installation

This package requires pdf-lib to be installed in your project:

npm install @smontero/pdf-utils pdf-lib

CLI Usage

The package provides two main CLI tools: get-fields and fill-pdf.

1. Identify Form Fields

Use get-fields to analyze a PDF and see what fields are available to fill.

npx get-fields my-form.pdf

Example Output:

Analyzing PDF: my-form.pdf
Total fields found: 2

-------------------------------------------------
Field Name: full_name
Retrieve Key (form.getField(...)): "full_name"
Type: TextField
Page(s): 1
-------------------------------------------------
Field Name: country
Type: Dropdown
Options:
  - "US" -> "United States"
  - "MX" -> "Mexico"
...

2. Fill a PDF Form

Create a JSON file with your data and use fill-pdf to generate a populated PDF.

data.json:

{
  "full_name": "John Doe",
  "country": "US"
}

Run the command:

npx fill-pdf input.pdf data.json output.pdf

To flatten the PDF (make it non-editable), add flatten at the end:

npx fill-pdf input.pdf data.json output.pdf flatten

Library Usage

You can also use the core logic in your own TypeScript/JavaScript projects.

import { fillPDFForm } from '@smontero/pdf-utils';
import * as fs from 'fs';

async function main() {
  const pdfBytes = fs.readFileSync('form.pdf');
  const values = {
    "first_name": "Jane",
    "is_subscribed": true
  };

  const pdfDoc = await fillPDFForm(pdfBytes, values, { flatten: true });
  const outputBytes = await pdfDoc.save();
  
  fs.writeFileSync('filled.pdf', outputBytes);
}

main();

Development

Build

To compile the TypeScript source into the dist/ directory:

npm run build

Test

(Tests are not yet implemented in this version)

npm test

License

ISC