node-pdf2img
A nodejs module for converting pdf into image file
Installation
$ [sudo] npm install pdf2img
Usage
var fs = require('fs');
var pdf2img = require('pdf2img');
var input = __dirname + '/sweetdocument.pdf';
pdf2img.setOptions({
type: 'png', // png or jpeg, default png
size: 1024, // default 1024
density: 600, // default 600
outputdir: __dirname + '/output' // mandatory, outputdir must be absolute path
});
pdf2img.convert(input, function(info) {
console.log(info);
});
It will return array of splitted and converted image files.
[ { page: 1,
name: 'test_1.png',
path: '/path-to-your-project/output/test_1.png' },
{ page: 2,
name: 'test_2.png',
path: '/path-to-your-project/output/test_2.png' },
{ page: 3,
name: 'test_3.png',
path: '/path-to-your-project/output/test_3.png' } ]
Note that pdf2img will split and convert all pages.
To Do
- Output file name option
- Convert selected pages
Maintainer
License
MIT