0.1.2 • Published 6 years ago

@tepez/pdf-to-png v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

pdf-to-png

Convert PDF to PNG using imagemagick6

npm version Build Status

This is essentially a small wrapper around imagemagick-stream that make it easier to use when writing tests for PDF files.

Important note - all imagemagick errors are ignored because it's very difficult to tell fatal errors from just warnings.

Install

npm install --save @tepez/pdf-to-png

Usage

const PdfToPng = require('@tepez/pdf-to-png');
const Fs = require('fs');

const pdf = Fs.readFileSync('/path/to/doc.pdf', null);
PdfToPng.pdfToPngBuffer(pdf, 0).then((png) => {
    Fs.writeFileSync('/path/to/doc.png', png, null);
})

API

pdfToPngStream(pdf: Buffer | Stream.Readable, page: number): Stream.Readable;
pdfToPngBuffer(pdf: Buffer | Stream.Readable, page: number): Promise<Buffer>;

Install dependencies

Windows

Ubuntu

sudo apt-get install imagemagick

TODO find a way to restrict to imagemagick6 (imagemagick-6.q16 does not include the binaries)