convert-pdf-png

0.0.1 • Public • Published

convert-pdf-png · Github license npm version Downloads

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 the Array.
  • Easy Configuration: The functions only contains two parameters, Pdf and Config, 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);
        });
    }
}
...

Package Sidebar

Install

npm i convert-pdf-png

Weekly Downloads

27

Version

0.0.1

License

MIT

Unpacked Size

4.11 kB

Total Files

4

Last publish

Collaborators

  • jamyth