convert-pdf-png ·
A Very Easy library for you to convert any pdf files no matter how many pages they are. Convert them into png files.
- File In & Files Out: simply pass the pdf file from
<input type='file' />
into the function, it converts every page of your pdf into png files and returns theArray
.
- Easy Configuration: The functions only contains two parameters,
Pdf
andConfig
, no need to set complex codes.
Installation
With npm:
npm install --save convert-pdf-png
Other dependencies you need to install:
- pdfjs-dist
npm install --save pdfjs-dist
- file-saver
npm install --save file-saver
- jszip
npm install --save jszip
Usage
import { convertPdfToPng } from 'convert-pdf-png';
...
const convertAndDownload = e => {
const pdf = e.target.files[0];
convertPdfToPng(pdf, {
outputType: 'download',
});
}
// ** or **
const convertAndDoSomething = e => {
const pdf = e.target.files[0];
convertPdfToPng(pdf, {
outputType: 'callback',
callback: callback
});
const callback = images => {
// the function returns an array
// every img is a normal file object
images.forEach(img => {
console.log(img.filename);
});
}
}
...