PHPackages                             machinateur/php-qpdf-ffi - 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. machinateur/php-qpdf-ffi

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

machinateur/php-qpdf-ffi
========================

A really simple PHP integration for qpdf leveraging its JSON job file functionality with PHP-FFI to C.

1.1.0(1y ago)236MITPHPPHP &gt;=7.4

Since Oct 26Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (3)Used By (0)

php-qpdf-ffi
============

[](#php-qpdf-ffi)

A really simple PHP integration for [qpdf](https://github.com/qpdf/qpdf) leveraging its JSON job file functionality with PHP-FFI to C.

The name really says it all.

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

[](#requirements)

- At least PHP `>=7.4` is required
    - Extensions `ext-json` and `ext-ffi` are required
- A compatible `qpdf` binary, version `11.9`
    - Some earlier versions might also work, as long as the C API is untouched

The PHP-FFI extension is supported since PHP version 7.4, so that's why it is the minimum PHP version this library supports and will support indefinitely.

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

[](#installation)

```
composer require machinateur/php-qpdf-ffi
```

The path to the C library should be specified by means of the `LIB_QPDF_PATH` constant. If not defined, a `\CompileError` will be thrown upon calling a function.

### Where to get the `qpdf` binaries

[](#where-to-get-the-qpdf-binaries)

Since qpdf is a separate C library, the binaries are not included here (yet). The [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0) allows redistribution.

>

Advantages
----------

[](#advantages)

Use the full set of features provided by qpdf JSON job files directly from within PHP, without the need to write any C glue code for a custom PHP extension.

No need for `\exec()` shenanigans. The PHP-FFI layer handles the direct interaction. This library only integrates one single function, therefor very little can break.

The JSON format can be dynamically generated based on the requirements of your application. As JSON is supported in a wide range of programming languages, the input does not necessarily have to come from PHP.

>

Usage
-----

[](#usage)

```
