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

@nerem/pdf2png

v1.0.0

Published

Convert PDF files to PNG images with customizable DPI and page selection

Readme

pdf2png

Convert PDF files to PNG images with customizable DPI and page selection.

Features

  • Convert entire PDFs or specific page ranges to PNG images
  • Customizable DPI/resolution (default: 150 DPI)
  • Progress bar showing conversion status
  • TypeScript-based for type safety
  • Simple CLI interface
  • Uses PDF.js for reliable PDF rendering

Installation

Global Installation (Recommended for CLI usage)

npm install -g pdf2png

Local Installation

npm install pdf2png

Usage

Basic Usage

Convert all pages of a PDF to PNG images:

pdf2png input.pdf output

This will create output1.png, output2.png, output3.png, etc. for each page in the PDF.

Custom DPI

Specify a custom DPI for higher or lower resolution output:

# High resolution (300 DPI)
pdf2png input.pdf output --dpi 300

# Low resolution for thumbnails (72 DPI)
pdf2png input.pdf output --dpi 72

DPI Reference:

  • 72 DPI: Screen resolution, smaller files
  • 150 DPI: Default, good balance of quality and file size
  • 300 DPI: Print quality, larger files

Page Range Selection

Convert specific pages or page ranges:

# Convert only pages 1-5
pdf2png input.pdf output --pages 1-5

# Convert pages 1, 3, and 5-10
pdf2png input.pdf output --pages 1,3,5-10

# Convert only page 7
pdf2png input.pdf output --pages 7

Disable Progress Bar

If you want to suppress the progress bar output:

pdf2png input.pdf output --no-progress

Full Example

pdf2png document.pdf page --dpi 300 --pages 1-10,15,20-25

This converts pages 1-10, 15, and 20-25 from document.pdf to PNG files at 300 DPI, creating:

  • page1.png
  • page2.png
  • ...
  • page10.png
  • page15.png
  • page20.png
  • ...
  • page25.png

CLI Options

Usage: pdf2png [options] <input-pdf> <output-scheme>

Arguments:
  input-pdf              Input PDF file path
  output-scheme          Output filename scheme (e.g., "output" creates output1.png, output2.png, ...)

Options:
  -V, --version          Output the version number
  --dpi <number>         DPI resolution for output images (default: "150")
  --pages <range>        Page range to convert (e.g., "1-5,7,10-12")
  --no-progress          Disable progress bar output
  -h, --help             Display help for command

Requirements

  • Node.js >= 16.0.0
  • npm or yarn

Technical Details

This package uses:

  • pdf-to-png-converter: Reliable PDF to PNG conversion library built on pdf-poppler
  • Commander.js: For CLI argument parsing
  • cli-progress: For progress bar display

Development

Setup

# Clone the repository
git clone <repository-url>
cd pdf2png

# Install dependencies
npm install

# Build the project
npm run build

Scripts

  • npm run build: Compile TypeScript to JavaScript
  • npm run dev: Run CLI directly with tsx (development mode)

Testing Locally

To test the CLI locally before publishing:

# Link the package globally
npm link

# Now you can use pdf2png command
pdf2png test.pdf output --dpi 300

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

If you encounter any issues or have suggestions, please file an issue on the GitHub repository.

Author

Created with TypeScript and PDF.js