PHPackages                             ottosmops/pdftotext - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. ottosmops/pdftotext

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

ottosmops/pdftotext
===================

Extract text from PDF

2.0.1(8mo ago)5143.7k↓23.9%1MITPHPPHP &gt;= 7.2CI passing

Since Nov 9Pushed 8mo ago3 watchersCompare

[ Source](https://github.com/ottosmops/pdftotext)[ Packagist](https://packagist.org/packages/ottosmops/pdftotext)[ Docs](https://github.com/ottosmops/pdftotext)[ RSS](/packages/ottosmops-pdftotext/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

Extract text from a PDF with pdftotext
======================================

[](#extract-text-from-a-pdf-with-pdftotext)

[![codecov](https://camo.githubusercontent.com/f05862b7c7223b4663edc2a0c5cc9204afd68f167b5b42fdf4548a3601863436/68747470733a2f2f636f6465636f762e696f2f67682f6f74746f736d6f70732f706466746f746578742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/ottosmops/pdftotext)[![Software License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Stable Version](https://camo.githubusercontent.com/03629df019c426201598a30fad5cbc8b2b5a219c576963fd4ec99e9dd2d9496b/68747470733a2f2f706f7365722e707567782e6f72672f6f74746f736d6f70732f706466746f746578742f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/ottosmops/pdftotext)[![Packagist Downloads](https://camo.githubusercontent.com/ce454a1b81691b42e227bebf40a8c9bebe79d9886f9cd2181fede4ad55a348a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f74746f736d6f70732f706466746f746578742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ottosmops/pdftotext)

This package provides a class to extract text from a pdf.

```
\Ottosmops\Pdftotext\Extract::getText('/path/to/file.pdf') //returns the text from the pdf
```

Requirements
------------

[](#requirements)

The Package uses [pdftotext](https://en.wikipedia.org/wiki/Pdftotext). Make sure that this is installed: `which pdftotext`

For Installation see: [poppler-utils](https://poppler.freedesktop.org/)

If the installed binary is not found ("`The command "which pdftotext" failed.`") you can pass the full path to the `_constructor` (see below) or use `putenv('PATH=$PATH:/usr/local/bin/:/usr/bin')` (with the dir where pdftotext lives) before you call the class `Extract`.

Installation
------------

[](#installation)

```
composer require ottosmops/pdftotext
```

Usage
-----

[](#usage)

Extracting text from a pdf:

```
$text = (new Extract())
  ->pdf('file.pdf')
  ->text();
```

**Security note:**If you pass user input as options or filenames to the library, make sure to validate or escape them to avoid shell injection. The library uses symfony/process, which provides basic protection, but unsafe options could still cause issues.

You can set the binary and you can specify options:

```
$text = (new Extract('/path/to/pdftotext'))
  ->pdf('path/to/file.pdf')
  ->options('-layout')
  ->text();
```

Default options are: `-eol unix -enc UTF-8 -raw`

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance60

Regular maintenance activity

Popularity37

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~643 days

Recently: every ~672 days

Total

6

Last Release

261d ago

Major Versions

v1.0.3 → v2.0.02019-07-24

PHP version history (2 changes)v1.0.0PHP &gt;=5.6.0

v2.0.0PHP &gt;= 7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/76f31e7e6772db47a91388ed82840fae1fa57185bb82a64924bb3839697222c2?d=identicon)[ottosmops](/maintainers/ottosmops)

---

Top Contributors

[![ottosmops](https://avatars.githubusercontent.com/u/4144389?v=4)](https://github.com/ottosmops "ottosmops (34 commits)")[![tzkoshi](https://avatars.githubusercontent.com/u/3149847?v=4)](https://github.com/tzkoshi "tzkoshi (1 commits)")

---

Tags

laravelpdftotextantonottosmops

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ottosmops-pdftotext/health.svg)

```
[![Health](https://phpackages.com/badges/ottosmops-pdftotext/health.svg)](https://phpackages.com/packages/ottosmops-pdftotext)
```

###  Alternatives

[lsnepomuceno/laravel-a1-pdf-sign

Sign PDF files with valid x509 certificates

315101.4k](/packages/lsnepomuceno-laravel-a1-pdf-sign)[mostafaznv/pdf-optimizer

PDF optimization tool for PHP and Laravel applications

170125.8k](/packages/mostafaznv-pdf-optimizer)[danielboendergaard/phantom-pdf

A Package for generating PDF files using PhantomJS

72467.9k](/packages/danielboendergaard-phantom-pdf)[nilgems/laravel-textract

A Laravel package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring "npm textract".

195.2k](/packages/nilgems-laravel-textract)[wrseward/pdf-parser

PHP library to parse text from PDF files

185.6k](/packages/wrseward-pdf-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
