pdftotextjs

0.5.1 • Public • Published

pdftotextjs - pdftotext shell wrapper for Node.js

view on npm npm module downloads Dependency Status Build Status Known Vulnerabilities view on npm

pdftotextjs provides access to pdftotext via shell in nodejs. You'll need pdftotext which comes with poppler-utils.

  • Ubuntu/Debian sudo apt-get install poppler-utils.
  • MacOSX sudo port install poppler or brew install xpdf.
  • Windows download and install Xpdf.

Installation

via npm:

$ npm install pdftotextjs

Usage

Asynchronous example

const pdftotext = require('pdftotextjs');
const pdf = new pdftotext('test/pdfs/sample.pdf');
 
// Convert first page only
// These options will be passed to pdftotext
// You may use any valid option
pdf.add_options(['-f 1', '-l 1']);
 
pdf.getText()
.then(result) {
  console.log(result);
})
.catch(function (err) {
  console.error(err);
});
 

Synchronous example

const pdftotext = require('pdftotextjs');
const pdf = new pdftotext('test/pdfs/sample.pdf');
 
const data = pdf.getTextSync(); // returns buffer
console.log(data.toString('utf8'));

Tests

$ npm test

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i pdftotextjs

    Weekly Downloads

    371

    Version

    0.5.1

    License

    MIT

    Unpacked Size

    10.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • kemorian
    • warszk
    • iapain
    • lukaszsiromski
    • daniel.wiadro
    • shardiwal