pdfsnap is a simple Node.js utility for converting a PDF to a PNG or JPEG image using pdftoppm
.
- Supports PNG and JPEG formats.
- Uses
pdftoppm
for fast and accurate conversion. - Simple API for easy integration.
Ensure you have Poppler installed on your system:
sudo apt update && sudo apt install poppler-utils -y
brew install poppler
Then, install pdfsnap via npm or yarn:
npm install pdfsnap
yarn add pdfsnap
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));
This project is licensed under the MIT License - see the LICENSE file for details.