0.0.1 • Published 4 years ago

convert-pdf-png v0.0.1

Weekly downloads
102
License
MIT
Repository
-
Last release
4 years ago

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);
        });
    }
}
...