1.0.3 • Published 4 months ago

pdfsnap v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

pdfsnap

pdfsnap is a simple Node.js utility for converting a PDF to a PNG or JPEG image using pdftoppm.

Features

  • Supports PNG and JPEG formats.
  • Uses pdftoppm for fast and accurate conversion.
  • Simple API for easy integration.

Installation

Ensure you have Poppler installed on your system:

Ubuntu/Debian

sudo apt update && sudo apt install poppler-utils -y

macOS (via Homebrew)

brew install poppler

Then, install pdfsnap via npm or yarn:

npm install pdfsnap
yarn add pdfsnap

Usage

const { pdfsnap } = require('pdfsnap');

pdfsnap({
  pdfPath: 'sample.pdf',
  outputPath: 'output.png',
  format: 'png',
  dpi: 300,
})
  .then(filePath => console.log('Image saved at:', filePath))
  .catch(error => console.error('Error:', error));

License

This project is licensed under the MIT License - see the LICENSE file for details.