Enterprise PDF for PHP

The enterprise PDF library
PHP doesn't have.

Generate archival PDF/A, sign documents with PAdES, encrypt with AES-256 and produce accessible PDF/UA from plain PHP. One memory-safe core, the same behavior as every other binding, running entirely on your servers: no per-document SaaS fees, no data leaving your network, no AGPL strings.

Install from Packagist. Pure PHP; the native core is fetched on first use.
composer require rust-pdf/rustpdf
Validated by independent tools: veraPDFpdfsigopenssl cmsqpdfmutool

Why PHP teams pick rust-pdf

PHP runs a huge share of the world's invoicing, billing and government portals, exactly where PDF/A archival, qualified signatures, AES-256 and PDF/UA are required. Yet the classic options (TCPDF, FPDF, dompdf) predate those standards, so teams bolt on headless Chrome or pay a per-document SaaS that ships their documents off-site.

rust-pdf is one composer require using the FFI extension. The package is pure PHP; the native core for your platform loads on first use, with every feature free.

  • Standards-grade, not a legacy lib: real PDF/A, PAdES and PDF/UA, not just box-and-text drawing.
  • Runs on your servers: documents never leave your network and nothing phones home, ideal for LGPD/GDPR, fintech and health.
  • No AGPL trap: MIT licensed, never the AGPL of iText or the per-server billing of Aspose.
  • Deterministic output: the same input always produces the same bytes, so you can diff and audit it.
  • Free to build with: every feature is free forever.

Every feature is free.

Prototype and ship everyday PDFs for free. PDF/A, signatures, encryption and accessibility are all included in PHP and every other binding.

Core free

  • Pages & vector graphics
  • Embedded/subset fonts, Unicode shaping
  • Justified paragraphs & tables
  • Images (JPEG/PNG/alpha/16-bit)
  • Merge / split / rotate
  • Text extraction & optimize

Advanced free

  • PDF/A: 1b / 2b / 2a / 3b / 3a / 4 / 4e / 4f archival
  • Digital signatures: PKCS#7, visible & multiple
  • PAdES: B-B / B-LT / B-LTA + RFC 3161 timestamps
  • Encryption: RC4 / AES-128 / AES-256 (R6)
  • Accessibility: Tagged PDF / PDF/UA-1
  • AcroForm: fields with generated appearances
  • Validate & convert: verify signatures, PDF→PDF/A, ZUGFeRD/Factur-X
  • Process: redaction, image extraction, form fill/flatten, page→PNG

Every feature is free.

rust-pdf is MIT licensed — PDF/A, digital signatures, encryption, accessibility and page rendering are all included. No key, no account, no card.

Author a tagged PDF/A in a few lines of PHP

// composer require rust-pdf/rustpdf
use RustPdf\Document;
use RustPdf\PdfaLevel;

$doc = new Document();
$doc->pdfa(PdfaLevel::A2a)->tagged()->setInfo(title: 'Q3 Report');
$f = $doc->addFontFile('Roboto-Regular.ttf');
$doc->addPage()->showText($f, 26, 72, 760, 'Annual report', 1); // H1
$bytes = $doc->toBytes();          // archival-grade, accessible PDF

The full PHP reference (fonts, images, forms, manipulation, encryption and signatures) lives in the PHP docs.

Fits Laravel, Symfony and plain PHP

toBytes() returns a binary string, so streaming a PDF is a Laravel response($bytes)->header('Content-Type', 'application/pdf'), a Symfony Response with the same header, or a bare header() + echo in any framework. No shell_exec to wkhtmltopdf, no temp directory to clean up.

The package is pure PHP over the bundled FFI extension, so composer require rust-pdf/rustpdf needs no native build. Enable ext-ffi in php.ini and the native core for your platform loads on first use, including under FPM and Octane.

// Laravel: return a PDF/A from a controller
use RustPdf\Document;
use RustPdf\PdfaLevel;

public function invoice()
{
    $doc = new Document();
    $doc->pdfa(PdfaLevel::A2b);
    $f = $doc->addFontFile('Roboto-Regular.ttf');
    $doc->addPage()->showText($f, 18, 72, 760, 'Invoice #1024');
    return response($doc->toBytes())
        ->header('Content-Type', 'application/pdf');
}

Common PDF tasks in PHP

Focused, copy-paste guides in PHP, all backed by the same Rust core. Each one uses the same fluent Document / EditableDoc API.

Start building in PHP

One Rust core, the same output in every language — free and MIT licensed.

PHP PDF library FAQ

What do I need to install besides Composer?

PHP 8.1+ with the FFI extension enabled (ffi.enable in php.ini). The Composer package is pure PHP and carries the native core per platform, so there is no native build, no PECL compile and no system PDF tool to install.

Does it work under PHP-FPM, Octane and Swoole?

Yes. The native core loads on first use within the worker process and stays resident, which suits long-lived FPM and Octane / Swoole workers. Each Document is independent, so concurrent requests do not share state.

How do I send the PDF from Laravel or Symfony?

toBytes() returns a binary string. Wrap it in a Laravel response() or a Symfony Response with Content-Type: application/pdf (and a Content-Disposition header for downloads). No files touch disk unless you choose to save them.