node-pdf2img-promises
An fork from node-pdf2img-promises by Jonathas Ribeiro.
A Node.js module for converting a pdf into an image file, using Promises.
This module is based on pdf2img by Fitra Aditya.
- It was completely refactored to use async/await instead of callbacks
- Error handling was improved
- The async lib dependency was removed
- An option to inform the desired image quality was implemented
- The lib is now an EventEmitter, so you can listen to the file conversion progress
Dependencies
These dependencies must be installed on your server, as the gm package uses them:
- GraphicsMagick
- GhostScript
Installation
$ npm install node-pdf2img-promises
Usage
const fs = ;const path = ;const Pdf2Img = ; let input = __dirname + '/test.pdf';let fileName = 'test'; let converter = ; // The event emitter is emitting to the file nameconverter; converter; converter
It will return array of splitted and converted image files.
result: 'success' message: page: 1 name: 'test_1.jpg' size: 17275 path: '/output/test_1.jpg' page: 2 name: 'test_2.jpg' size: 24518 path: '/output/test_2.jpg' page: 3 name: 'test_3.jpg' size: 24055 path: '/output/test_3.jpg'
Maintainer
License
MIT