PHPackages                             sgh/pdfbox - 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. sgh/pdfbox

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

sgh/pdfbox
==========

PHP5 wrapper for the Apache PdfBox ExtractText utility.

v1.0.0(10y ago)2098.2k↓26.7%8[1 issues](https://github.com/schmengler/PdfBox/issues)[2 PRs](https://github.com/schmengler/PdfBox/pulls)5BSDPHPPHP &gt;=5.3.0

Since Jun 25Pushed 7y ago4 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (5)

PdfBox
======

[](#pdfbox)

A PHP interface for the [PdfBox ExtractText](http://pdfbox.apache.org/commandline/#extractText) utility, useful to unit-test contents of generated PDFs.

[![Build Status](https://camo.githubusercontent.com/30210f0bebc3a28bad146609038914991f56a1e35a375733242f1586bcb580a1/68747470733a2f2f7472617669732d63692e6f72672f7363686d656e676c65722f506466426f782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/schmengler/PdfBox) [![Latest Stable Version](https://camo.githubusercontent.com/24c70238d192c7f29fe98412627c4351ee383f397269d83a796f10718745361d/68747470733a2f2f706f7365722e707567782e6f72672f7367682f706466626f782f76657273696f6e)](https://packagist.org/packages/sgh/pdfbox) [![Latest Unstable Version](https://camo.githubusercontent.com/1670d02f8e881faffe0cd80fc7e7a37bef055ee86809a9b66a7173ff6fcc2d8e/68747470733a2f2f706f7365722e707567782e6f72672f7367682f706466626f782f762f756e737461626c65)](//packagist.org/packages/sgh/pdfbox) [![Total Downloads](https://camo.githubusercontent.com/21f23773704bedab56b8e72d66fba55c1c8ba39fcc59a0807b31a124f0713ad6/68747470733a2f2f706f7365722e707567782e6f72672f7367682f706466626f782f646f776e6c6f616473)](https://packagist.org/packages/sgh/pdfbox) [![License](https://camo.githubusercontent.com/787f30bc32836125bf2c144ae30242b304b4e933fcd9a3bb98b413c0df77e6aa/68747470733a2f2f706f7365722e707567782e6f72672f7367682f706466626f782f6c6963656e7365)](https://packagist.org/packages/sgh/pdfbox)

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

[](#requirements)

- PHP &gt;=5.3 or HHVM
- Java Runtime Environment
- PdfBox JAR file
    - Download:
    - Minimum version: 1.2.0
    - Recommended version: &gt;= 1.8.3
- PHP needs permissions for shell execution

Install
-------

[](#install)

To install with composer:

```
composer require sgh/pdfbox
```

Basic Usage
-----------

[](#basic-usage)

```
use SGH\PdfBox\PdfBox;

//$pdf = GENERATED_PDF;
$converter = new PdfBox;
$converter->setPathToPdfBox('/usr/bin/pdfbox-app-1.7.0.jar');
$text = $converter->textFromPdfStream($pdf);
$html = $converter->htmlFromPdfStream($pdf);
$dom  = $converter->domFromPdfStream($pdf);
```

If the source PDF is a file, use `xxxFromPdfFile()` instead `xxxFromPdfStream()` with the source path as parameter.

If you want to save the converted output to a file, specify the destination path as second parameter of the `xxxFromPdfxxx()` methods.

Advanced Usage
--------------

[](#advanced-usage)

Convert a range of pages instead of the full document:

```
$converter->getOptions()
    ->setStartPage(2)
	->setEndPage(5);
```

Ignore corrupt objects in the PDF:

```
$converter->getOptions()
    ->setForce(true);
```

Sort text:

```
$converter->getOptions()
    ->setSort(true);
```

PHPUnit tests
-------------

[](#phpunit-tests)

To run the unit tests, change the environment variable `PDFBOX_JAR` to the full path of your PdfBox JAR file. See *phpunit.xml.dist*.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

Unknown

Total

1

Last Release

3981d ago

### Community

Maintainers

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

---

Top Contributors

[![z38](https://avatars.githubusercontent.com/u/3948085?v=4)](https://github.com/z38 "z38 (3 commits)")[![royopa](https://avatars.githubusercontent.com/u/442991?v=4)](https://github.com/royopa "royopa (2 commits)")[![georgeenciu](https://avatars.githubusercontent.com/u/1264087?v=4)](https://github.com/georgeenciu "georgeenciu (1 commits)")

---

Tags

pdfpdfbox

### Embed Badge

![Health badge](/badges/sgh-pdfbox/health.svg)

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[tecnickcom/tcpdf

TCPDF is a PHP class for generating PDF documents and barcodes.

4.5k101.8M473](/packages/tecnickcom-tcpdf)[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k77.1M493](/packages/mpdf-mpdf)[knplabs/knp-snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.

4.5k68.3M56](/packages/knplabs-knp-snappy)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)

PHPackages © 2026

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