PHPackages                             rust-pdf/rustpdf - 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. rust-pdf/rustpdf

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

rust-pdf/rustpdf
================

Generate, edit, sign and process PDFs in PHP: PDF/A, AES-256 encryption, digital signatures (PAdES), forms, stamping, redaction, text extraction and page rendering. Docs: https://rustpdf.dev/docs/php

v0.4.8(1mo ago)04proprietaryPHPPHP &gt;=8.1

Since Jun 27Pushed 1mo agoCompare

[ Source](https://github.com/rustpdf/rustpdf-php)[ Packagist](https://packagist.org/packages/rust-pdf/rustpdf)[ Docs](https://rustpdf.dev/docs/php)[ RSS](/packages/rust-pdf-rustpdf/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (8)DependenciesVersions (10)Used By (0)

RustPdf for PHP
===============

[](#rustpdf-for-php)

Generate, edit, sign and process PDFs from PHP: vector graphics, embedded fonts and Unicode text, wrapping paragraphs, images, **PDF/A** (1b-4f), **tagged/accessible** output, attachments, **AcroForm** fields, page manipulation (merge/split/stamp), watermarks, true **redaction**, **AES-256** encryption, **digital signatures (PAdES)** with HSM/deferred signing, timestamps/LTV, text extraction and search, and page **rendering to PNG**. Uses the built-in FFI extension (PHP 8.1+), nothing to compile.

Documentation
-------------

[](#documentation)

- **Full API reference:**
- **Interactive positioning guide** (coordinates, anchors, rotation):
- All product guides (PDF/A, signatures, encryption, redaction, rendering):

Classes (namespace `RustPdf`, PSR-4 under `src/`):

- `Pdf` — static helpers (`version`, `activateLicense`, `extractText`, `sign`, `timestamp`, `addDss`, plus deferred/HSM signing: `signWith`, `beginSigning`, `completeSignature`, `listSignatures`);
- `Document` — fluent authoring API;
- `EditableDoc` — manipulation API;
- `PdfaLevel`, `Align`, `AFRelationship`, `Encryption` — enums;
- `PdfException`, `Ffi` (internal FFI loader).

Install
-------

[](#install)

```
composer require rust-pdf/rustpdf
```

The package is pure PHP; the native `libpdf_ffi` is fetched per platform from the GitHub Release. `Ffi::libPath()` resolves it in this order:

1. `RUSTPDF_LIB` — an absolute path to a library you provide (always wins);
2. the bundled copy under `lib/-/`, placed there by the installer;
3. the dev tree (`target/{debug,release}`, walking up from `src/`);
4. **lazy download** of the matching prebuilt library on first use.

Because Composer only runs scripts for the *root* package (never a dependency), the download can't fire automatically on `composer require`. The step-4 lazy fetch covers most setups with zero config, but if your production filesystem is read-only, fetch the library **once at deploy/CI time** instead:

```
php vendor/rust-pdf/rustpdf/bin/rustpdf-install-lib
```

Or wire it into your **root** `composer.json`:

```
"scripts": {
  "post-install-cmd": "@php vendor/rust-pdf/rustpdf/bin/rustpdf-install-lib",
  "post-update-cmd":  "@php vendor/rust-pdf/rustpdf/bin/rustpdf-install-lib"
}
```

Set `RUSTPDF_NO_DOWNLOAD=1` to forbid the network fetch (you must then supply the library via `RUSTPDF_LIB` or a local `cargo build -p pdf-ffi --release`).

### Enabling `ext-ffi`

[](#enabling-ext-ffi)

FFI ships with PHP 8.1+ but is often **disabled in production**. In CLI it's enabled by default; for FPM/web set in `php.ini`:

```
extension=ffi
ffi.enable=true        ; or, hardened: ffi.enable=preload + ffi.preload=...
```

Without it, install succeeds but the first call throws.

Quick start
-----------

[](#quick-start)

```
