# pdf-to-text

> Extract the text from pdf files

Latest version **0.0.7** (published 2018-07-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install pdf-to-text
pnpm add pdf-to-text
yarn add pdf-to-text
bun add pdf-to-text
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2018-07-27 |
| First published | 2014-10-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 80 |
| Author | Fernando Hernandez |
| Maintainers | zetahernandez |
| Keywords | pdf, text, extract, convert, parse, info, pdf-to-text, pdftotext, nodejs |

## Links

- npm: https://www.npmjs.com/package/pdf-to-text
- Repository: https://github.com/zetahernandez/pdf-to-text
- Issues: https://github.com/zetahernandez/pdf-to-text/issues
- npm.io page: https://npm.io/package/pdf-to-text

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2018-07-27
- 0.0.6 — 2014-10-11
- 0.0.5 — 2014-10-10
- 0.0.4 — 2014-10-08
- 0.0.3 — 2014-10-08
- 0.0.2 — 2014-10-08
- 0.0.1 — 2014-10-08
- 0.0.0 — 2014-10-08

## README

# PDF-TO-TEXT
pdf-to-text is a tool to extract text from pdf. for the moment not support ocr scannig to extract text only works for searchable pdf files. This package doesn't have nodejs dependencies. 

[![Build Status](https://travis-ci.org/zetahernandez/pdf-to-text.png)](https://travis-ci.org/zetahernandez/pdf-to-text)

## Installation

To install the module.
`npm install pdf-to-text`

You need install the next tools to use this module


- pdftotext
    - pdftotext is used to extract text out of searchable pdf documents
- pdfinfo
    - pdfinfo is used to obtain the info of pdf documents

### OSX
To begin on OSX, first make sure you have the homebrew package manager installed.


**pdftotext** is included as part on the xpdf utilities library. **xpdf** can be installed via homebrew
``` bash
brew install xpdf
```

### Ubuntu

**pdftotext** is included in the **poppler-utils** library. To installer poppler-utils execute
``` bash
apt-get install poppler-utils
```


## Usage
=======

### PDF Info

Obtain info from pdf file
```js
var pdfUtil = require('pdf-to-text');
var pdf_path = "absolute_path/to/pdf_file.pdf";

pdfUtil.info(pdf_path, function(err, info) {
    if (err) throw(err);
    console.log(info);
});
```

It's retrieve an object with the data info from the pdf file

``` json
{ "title": "some title",
  "subject": "TeX output 2003.10.17:1908",
  "author": "Fernando Hernandez",
  "creator": "creator name",
  "producer": "Acrobat Distiller 4.0 for Windows",
  "creationdate": 1066428670000,
  "moddate": 1066428687000,
  "tagged": "no",
  "form": "none",
  "pages": 8,
  "encrypted": "no",
  "page_size": "612 x 792 pts (letter)",
  "file_size": "28695 bytes",
  "optimized": "yes",
  "pdf_version": "1.2" 
  }
```

### PDF Text extract

You can extract text by a range of pages given an option object with **from** and **to** properties, or simply omit this option to extract all text from the pdf file

```js
var pdfUtil = require('pdf-to-text');
var pdf_path = "absolute_path/to/pdf_file.pdf";

//option to extract text from page 0 to 10
var option = {from: 0, to: 10};

pdfUtil.pdfToText(upload.path, option, function(err, data) {
  if (err) throw(err);
  console.log(data); //print text    
});

//Omit option to extract all text from the pdf file
pdfUtil.pdfToText(upload.path, function(err, data) {
  if (err) throw(err);
  console.log(data); //print all text    
});
```


## Tests

To test that your system satisfies the needed dependencies and that module is functioning correctly execute the command in the pdf-to-text module folder
```
cd <project_root>/node_modules/pdf-to-text
npm test
```

---
_Source: https://npm.io/package/pdf-to-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
