A Node.js module for converting a pdf into an image file, using Promises.
- 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
These dependencies must be installed on your server, as the gm package uses them:
$ npm install pdf2img-promises
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: 1name: 'test_1.jpg'size: 17275path: '/output/test_1.jpg'page: 2name: 'test_2.jpg'size: 24518path: '/output/test_2.jpg'page: 3name: 'test_3.jpg'size: 24055path: '/output/test_3.jpg'