# pdf-parse2

> A pure JavaScript, cross-platform module designed for extracting text from PDF files.

Latest version **1.0.4** (published 2024-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install pdf-parse2
pnpm add pdf-parse2
yarn add pdf-parse2
bun add pdf-parse2
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2024-03-15 |
| First published | 2024-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 1 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | necm1 |
| Maintainers | necm1 |
| Keywords | pdf-parse, pdf-crawler, xpdf, pdf.js, pdfreader, pdf2json, j-pdfjson, pdf-parser, pdf-extract, pdf-extractor, pdf-to-text, pdf-text-extract, pdfjs, server side PDF parsing, pdf metadata |

## Links

- npm: https://www.npmjs.com/package/pdf-parse2
- Repository: https://github.com/necm1/pdf-parse2
- Issues: https://github.com/necm1/pdf-parse2/issues
- npm.io page: https://npm.io/package/pdf-parse2

## Dependencies (1)

- [pdfjs-dist](https://npm.io/package/pdfjs-dist.md) ^4.0.379

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.4 (latest) — 2024-03-15
- 1.0.3 — 2024-03-15
- 1.0.2 — 2024-03-15
- 1.0.1 — 2024-03-15
- 1.0.0 — 2024-03-15

## README

[![version](https://img.shields.io/npm/v/pdf-parse.svg)](https://www.npmjs.org/package/pdf-parse2)
[![downloads](https://img.shields.io/npm/dt/pdf-parse2.svg)](https://www.npmjs.org/package/pdf-parse2)
![license](https://img.shields.io/npm/l/pdf-parse2)
[![node](https://img.shields.io/node/v/pdf-parse2.svg)](https://nodejs.org/)
![type](https://img.shields.io/npm/types/pdf-parse2)
![size](https://img.shields.io/npm/unpacked-size/pdf-parse2)

# PDF Parse

A pure JavaScript, cross-platform module designed for extracting text from PDF files using [pdf.js](https://mozilla.github.io/pdf.js/).

## Features

- Extract text from PDF files.
- Supports both browser and Node.js environments.
- Easy to use with promise-based API.

## Installation

```bash
npm install pdf-parse2
```

Or

```bash
yarn add pdf-parse2
```

## Usage

### Node.js

```javascript
const fs = require('fs');
const PDFParse = require('pdf-parse2');

(async () => {
  const dataBuffer = fs.readFileSync('path/to/your/document.pdf');
  const PDFParse = new PDFParse();

  try {
    const pdfData = await PDFParse.loadPDF(dataBuffer);
    console.log('Text:', pdfData.text);
  } catch (error) {
    console.error(error);
  }
})();
```

### Browser

Ensure you include pdf.js library in your project. You can then use `PDFParse` similar to the Node.js example, but with fetching the PDF file using Fetch API or XMLHttpRequest.

## API Reference

- `loadPDF(src, options)`: Loads a PDF file and extracts text. `src` can be a `Buffer` or `ArrayBuffer`. `options` is optional.

- `renderPage(pageData, options)`: A helper function for rendering a single page. This function is used internally by `loadPDF`.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue for any bugs or feature requests.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

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