Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pdf-text-extract

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf-text-extract

Extract text from pdfs that contain searchable pdf text

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-7.55%
Maintainers
2
Weekly downloads
 
Created
Source

PDF Text Extract

Extract text from pdfs that contain searchable pdf text. The module is wrapper that calls the pdftotext command to perform the actual extraction

Build Status Dependency Status

Installation

npm install pdf-text-extract

You will need the pdftotext binary available on your path. There are packages available for many different operating systems

See https://github.com/nisaacson/pdf-extract#osx for how to install the pdftotext command

Usage

As a module

var filePath = path.join(__dirname, 'test/data/multipage.pdf')
var extract = require('pdf-text-extract')
extract(filePath, function (err, pages) {
  if (err) {
    console.dir(err)
    return
  }
  console.dir(pages)
})

The output will be an array of where each entry is a page of text. If you want just a string of all pages you can do pages.join(' ')

If needed you can pass an optional arguments to the extract function. These will be passed to the command

var filePath = path.join(__dirname, 'test/data/multipage.pdf')
var extract = require('pdf-text-extract')
var options = {
  cwd: "./"
}
extract(filePath, options, function (err, pages) {
  if (err) {
    console.dir(err)
    return
  }
  console.dir('extracted pages', pages)
})

As a command line tool

npm install -g pdf-text-extract

Execute with the filePath as an argument. Output will be json-formatted array of pages

pdf-text-extract ./test/data/multipage.pdf
# outputs
# ['<page 1 content...>', '<page 2 content...>']

Test

# install dev dependencies
npm install
# run tests
npm test

Keywords

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc