PHPackages                             mishahawthorn/ocrmypdf - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mishahawthorn/ocrmypdf

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mishahawthorn/ocrmypdf
======================

A simple PHP wrapper for OCRmyPDF

v1.0.0(7mo ago)9643↓33.3%2[1 PRs](https://github.com/mishahawthorn/ocrmypdf-php/pulls)AGPL-3.0-onlyPHPPHP ^8.0CI passing

Since May 31Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/mishahawthorn/ocrmypdf-php)[ Packagist](https://packagist.org/packages/mishahawthorn/ocrmypdf)[ RSS](/packages/mishahawthorn-ocrmypdf/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (12)Used By (0)

ocrmypdf-php
============

[](#ocrmypdf-php)

A simple PHP wrapper for OCRmyPDF

[![Latest Stable Version](https://camo.githubusercontent.com/12cb407b7d3e4f9abf41e4961c3fc1f2a5c3b23d57201dc979fe71627efe65ae/687474703a2f2f706f7365722e707567782e6f72672f6d6973686168617774686f726e2f6f63726d797064662f76)](https://packagist.org/packages/mishahawthorn/ocrmypdf)[![Total Downloads](https://camo.githubusercontent.com/6d3651ec5c670bd48360f728993417c480d0dcd3b38ba7f1803ae674c51a764f/687474703a2f2f706f7365722e707567782e6f72672f6d6973686168617774686f726e2f6f63726d797064662f646f776e6c6f616473)](https://packagist.org/packages/mishahawthorn/ocrmypdf)[![License](https://camo.githubusercontent.com/e498af3edcbb778e5f0fc0193065a52b523fbb4abe4d7aa709a95b42abd7e637/687474703a2f2f706f7365722e707567782e6f72672f6d6973686168617774686f726e2f6f63726d797064662f6c6963656e7365)](https://packagist.org/packages/mishahawthorn/ocrmypdf)[![PHP Version Require](https://camo.githubusercontent.com/9c88f3396f034611237286a75e9a35ef8f170f855e1d3b4c774ec66fd04e4967/687474703a2f2f706f7365722e707567782e6f72672f6d6973686168617774686f726e2f6f63726d797064662f726571756972652f706870)](https://packagist.org/packages/mishahawthorn/ocrmypdf)[![codecov](https://camo.githubusercontent.com/b53d0b7b5e6170c045665b83b8b40c849eacc21b72cdd71ad773ad3e152568fb/68747470733a2f2f636f6465636f762e696f2f67682f6d6973686168617774686f726e2f6f63726d797064662d7068702f67726170682f62616467652e7376673f746f6b656e3d463343553954384c4a55)](https://codecov.io/gh/mishahawthorn/ocrmypdf-php)

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

[](#installation)

Via [Composer](http://getcomposer.org/):

```
$ composer require mishahawthorn/ocrmypdf

```

**This library depends on [OCRmyPDF](https://github.com/jbarlow83/OCRmyPDF).** Please see the GitHub repository for instructions on how to install OCRmyPDF on your platform.

Usage
-----

[](#usage)

### Basic example

[](#basic-example)

```
use mishahawthorn\OCRmyPDF\OCRmyPDF;

//Return file path of outputted, OCRed PDF
echo OCRmyPDF::make('document.pdf')->run();

//Return file contents of outputted, OCRed PDF
echo OCRmyPDF::make('scannedImage.png')->setOutputPDFPath(null)->run();
```

API
---

[](#api)

### setParam

[](#setparam)

Define invocation parameters for `ocrmypdf`. See `ocrmypdf --help` for a list of available parameters.

Important

Parameters configured via `setParam` will override any other parameters or configurations set otherwise.

```
use mishahawthorn\OCRmyPDF\OCRmyPDF;

//Passing a single parameter with a value
OCRmyPDF::make('document_zh-CN.pdf')
    ->setParam('-l', 'chi_sim')
    ->run();

//Passing a single parameter without a value
OCRmyPDF::make('document_withBackground.pdf')
    ->setParam('--remove-background')
    ->run();

//Passing multiple parameters
OCRmyPDF::make('document_withoutAttribution.pdf')
    ->setParam('--title', 'Lorem Ipsum')
    ->setParam('--keywords', 'Lorem,Ipsum,dolor,sit,amet')
    ->run();
```

### setInputData

[](#setinputdata)

Pass image/PDF data loaded in memory into `ocrmypdf` directly via stdin.

```
use mishahawthorn\OCRmyPDF\OCRmyPDF;

//Using Imagick
$data = $img->getImageBlob();
$size = $img->getImageLength();

//Using GD
ob_start();
imagepng($img, null, 0);
$size = ob_get_length();
$data = ob_get_clean();

OCRmyPDF::make()
    ->setInputData($data, $size)
    ->run();
```

### setOutputPDFPath

[](#setoutputpdfpath)

Specify a writable path where `ocrmypdf` should generate output PDF.

```
use mishahawthorn\OCRmyPDF\OCRmyPDF;
OCRmyPDF::make('document.pdf')
    ->setOutputPDFPath('/outputDir/ocr_document.pdf')
    ->run();
```

### setExecutable

[](#setexecutable)

Define a custom location of the `ocrmypdf` executable, if by any reason it is not present in the `$PATH`.

```
use mishahawthorn\OCRmyPDF\OCRmyPDF;
OCRmyPDF::make('document.pdf')
    ->setExecutable('/path/to/ocrmypdf')
    ->run();
```

License
-------

[](#license)

ocrmypdf-php is released under the [AGPL-3.0 License](https://github.com/mishahawthorn/ocrmypdf-php/blob/main/LICENSE).

Credits
-------

[](#credits)

Development of ocrmypdf-php is based on the [tesseract-ocr-for-php](https://github.com/thiagoalessio/tesseract-ocr-for-php) PHP wrapper library for `tesseract`developed by [thiagoalessio](https://github.com/thiagoalessio) and associated contributors.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance68

Regular maintenance activity

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~318 days

Recently: every ~165 days

Total

6

Last Release

216d ago

Major Versions

v0.4.0 → v1.0.02025-10-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/a5fa68fd562efc5ddae55c585124ce914209807a6ddbb8f6a3a44f3d3a2a5eeb?d=identicon)[mishahawthorn](/maintainers/mishahawthorn)

---

Top Contributors

[![mishahawthorn](https://avatars.githubusercontent.com/u/6118330?v=4)](https://github.com/mishahawthorn "mishahawthorn (35 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")

---

Tags

phpwrapperOCRocrmypdf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mishahawthorn-ocrmypdf/health.svg)

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

###  Alternatives

[zoon/rialto

Manage Node resources from PHP

12199.4k3](/packages/zoon-rialto)[wujunze/money-wrapper

MoneyPHP Wrapper

113.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

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