Coder Social home page Coder Social logo

quayspwn / node-poppler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fdawgs/node-poppler

0.0 0.0 0.0 34.38 MB

Asynchronous node.js wrapper for the Poppler PDF rendering library

License: MIT License

JavaScript 20.87% C++ 22.45% C 32.40% Roff 24.28%

node-poppler's Introduction

node-poppler

GitHub Release npm version Build Status Coverage Status Dependabot Status code style: prettier

Asynchronous node.js wrapper for the Poppler PDF rendering library

Intro

The node-poppler module was created out of a need for a PDF-to-HTML conversion module at Yeovil District Hospital NHSFT to convert clinical documents in PDF format to HTML.

Installation

Install using yarn:

yarn add node-poppler

Or npm:

npm install node-poppler

node-poppler's test scripts use yarn commands.

Linux support

Windows and OSX/Darwin binaries are provided with this repository. For Linux users, you will need to download the poppler-data and poppler-utils binaries seperately.

An example of downloading the binaries on a Debian system:

sudo apt-get install poppler-data
sudo apt-get install poppler-utils

Once they have been installed you will need to pass the poppler-utils installation directory in as parameters to an instance of the Poppler class:

const { Poppler } = require('node-poppler');
const poppler = new Poppler('./usr/bin');

API

const { Poppler } = require('node-poppler');

API Documentation can be found here

Examples

poppler.pdfToCairo

options object requires atleast one of the following to be set: jpegFile; pdfFile; pngFile; psFile; svgFile; tiffFile.

Example of calling poppler.pdfToCairo with a promise, to convert only the first and second page of a PDF file to PNG:

const { Poppler } = require('node-poppler');

const file = 'test_document.pdf';
const poppler = new Poppler();
const options = {
	firstPageToConvert: 1,
	lastPageToConvert: 2,
	pngFile: true
};

const res = await poppler.pdfToCairo(options, file);
console.log(res);

poppler.pdfToHtml

Every field of the options object is entirely optional.

Example of calling poppler.pdfToHtml with a promise:

const { Poppler } = require('node-poppler');

const file = 'test_document.pdf';
const poppler = new Poppler();
const options = {
	firstPageToConvert: 1,
	lastPageToConvert: 2
};

poppler.pdfToHtml(options, file).then((res) => {
	console.log(res);
});

poppler.pdfToText

Every field of the options object is entirely optional.

Example of calling poppler.pdfToText with a promise:

const { Poppler } = require('node-poppler');

const file = 'test_document.pdf';
const poppler = new Poppler();
const options = {
	firstPageToConvert: 1,
	lastPageToConvert: 2
};

poppler.pdfToText(options, file).then((res) => {
	console.log(res);
});

Contributing

Please see CONTRIBUTING.md for more details regarding contributing to this project.

License

node-poppler is licensed under the MIT license.

node-poppler's People

Contributors

dependabot-preview[bot] avatar fdawgs avatar greenkeeper[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.