PHPackages                             dragonofmercy/phppdf - 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. dragonofmercy/phppdf

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

dragonofmercy/phppdf
====================

Modern PHP library for PDF generation.

v1.12.0(4w ago)1639MITPHPPHP ^8.4CI passing

Since May 29Pushed 1mo agoCompare

[ Source](https://github.com/dragonofmercy/php-pdf)[ Packagist](https://packagist.org/packages/dragonofmercy/phppdf)[ RSS](/packages/dragonofmercy-phppdf/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (6)Versions (16)Used By (0)

 [![phppdf - modern PHP 8.4 library for PDF generation](https://raw.githubusercontent.com/dragonofmercy/php-pdf/main/.github/og-image.png)](https://raw.githubusercontent.com/dragonofmercy/php-pdf/main/.github/og-image.png)

phppdf
======

[](#phppdf)

[![Latest Version](https://camo.githubusercontent.com/c150a351cb14d8ab25f678a6f2f73e61e17ecf2c84118f4108dd411b5cc0ae2e/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f647261676f6e6f666d657263792f706870706466)](https://packagist.org/packages/dragonofmercy/phppdf)[![Total Downloads](https://camo.githubusercontent.com/983542d0cba74d403d655461f550e601d23cd73d05c80b48a8e81f44b1a9f2dc/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f647261676f6e6f666d657263792f706870706466)](https://packagist.org/packages/dragonofmercy/phppdf)[![PHP Version](https://camo.githubusercontent.com/0b960b189c8f41e855c2da88b3eace47fd32ddeeba2079c6d3bdef79c171b484/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f647261676f6e6f666d657263792f7068707064663f69636f6e3d706870)](https://www.php.net/)[![License](https://camo.githubusercontent.com/cc3736bb59177c3a14a9a69ccac14db38abb20e5689c8f01c10d586f52a69f13/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f647261676f6e6f666d657263792f706870706466)](LICENSE)[![Ko-fi](https://camo.githubusercontent.com/7a981a96a3766e463291eb835bb54c0cbaaa83268bbcb2afb9a8a4aabb3abfca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4b6f2d2d66692d537570706f72742d4646354535423f6c6f676f3d6b6f6669266c6f676f436f6c6f723d7768697465)](https://ko-fi.com/dragonofmercy)

Modern PHP 8.4 library for PDF generation. Pure PHP, no external runtime dependencies beyond the standard `mbstring`, `openssl`, and `zlib` extensions.

> **Status:** stable (1.0). The public API follows [semantic versioning](https://semver.org/); breaking changes are reserved for the next major version. See [CHANGELOG.md](CHANGELOG.md).

What works today
----------------

[](#what-works-today)

A quick tour - each feature has a full guide in the [wiki](#documentation).

**Create**

- 📄 **Documents** - 19 standard sizes (ISO A0-A7, B4 / B5, C-series envelopes, Letter / Legal / Tabloid / Executive / Half-Letter) plus custom sizes, portrait or landscape, multi-page, metadata, AES-256 password protection, viewer hints.
- 📐 **Coordinates** - millimetres by default (origin top-left), or PDF points via `Unit::PT`.
- ✏️ **Graphics** - lines, rectangles, circles, paths, fill / stroke, dashes, caps / joins, transforms.
- 🔤 **Text** - the 12 standard fonts, multi-line, configurable leading, full Western Latin, exact width measurement.
- 🔡 **Custom fonts** - register TrueType / OpenType families with full Unicode (Latin / Greek / Cyrillic / CJK), selectable text, automatic glyph subsetting.
- 📦 **Cells** - text boxes with borders, fill, padding, alignment (left / center / right / justify), word-wrap, three width-fit modes.
- 🖼️ **Images** - JPEG and PNG (all color types, transparency), embedded once and placed anywhere.
- 🎨 **SVG** - fully vector: shapes, paths, gradients, patterns, clipping, masks, CSS styling, selectable `` / ``, pure-PHP ``.
- 🔢 **Barcodes &amp; QR** - 1D (EAN-13 / 8, Code 128 / 39 / 93, UPC-A, ITF) and 2D (QR, Aztec, DataMatrix, PDF417), pure-PHP and vector.
- 📝 **Markdown** - a CommonMark core subset, flowing with automatic page breaks or inside an auto-sized cell, styleable via `MarkdownStyle`.
- 📊 **Tables** - data grids via `Page::table()`: fixed or `fill` columns, repeated headers, zebra striping, borders, per-cell styling, column spanning, grouped headers.
- 🧱 **Multi-column layout** - flow `cell()` and `markdown()` across equal-width columns with `$page->columns(...)`.
- 🔖 **Bookmarks &amp; hyperlinks** - a nested table-of-contents sidebar and clickable URL / page areas.
- 🧾 **Interactive forms** - text fields, checkboxes, radios, dropdowns, listboxes, buttons, with per-field styling, JavaScript actions, and field linking.
- ✍️ **Digital signatures** - real PKCS#7 / CMS via `Document::sign()`, RFC 3161 timestamps, multiple signers, PAdES B-B / B-T, and LTV building blocks.

**Right-to-left &amp; accessibility**

- 🔁 **Right-to-left text** - Unicode bidi reordering (UAX #9) plus Arabic cursive shaping (contextual forms + lam-alef ligatures) on cells, tables, and Markdown; per-document, per-cell, or per-block direction.
- 🗄️ **PDF/A archival** - PDF/A-1 (PDF 1.4-based, levels 1b / 1a, transparency rejected), PDF/A-2, PDF/A-3 (levels b / u / a), and PDF 2.0-based PDF/A-4 (+ A-4f) with one `enablePdfA()` call, veraPDF-validated; A-3 / A-4f embed Factur-X / ZUGFeRD e-invoices.
- ♿ **Tagged PDF &amp; PDF/UA-1** - opt-in tagging via `enableTagging()`; `enablePdfUA()` produces veraPDF-validated PDF/UA-1 with artifacts, figure alt text, table header scopes, and tagged hyperlinks.

**Read &amp; modify existing PDFs**

- 📖 **Reading** - `PdfReader` parses PDFs including encrypted ones (RC4 40/128-bit, AES-128, AES-256); pass an optional password or omit it for permissions-only encryption. Classic xref tables, cross-reference streams, incremental revisions, object streams, and common filters.
- 🧩 **Template import (FPDI-style)** - `Document::importPdf()` + `Page::template()` stamp any source page as a background or overlay: letterheads, watermarks, scanned-form fills. Encrypted source PDFs are supported (optional password).
- 🔧 **Modifying** - `PdfEditor::open()` saves changes as appended revisions, leaving the original bytes (and any signatures) intact: edit metadata, add pages, delete and reorder pages (bookmarks and links pointing at a removed page are cleaned up automatically), sign, timestamp, and enable LTV. Editing encrypted PDFs is supported - pass an optional password; signing an encrypted PDF is not yet supported.
- 🖋️ **Filling AcroForm fields** - inspect and `setField()` text / checkbox / radio / combobox / listbox values; each filled field gets a generated appearance. Fields that use a font embedded in the document (not only the standard 14) are supported too. `flattenFields()` freezes filled forms into static page content (all fields or a named subset; signature and button fields are kept). Works on encrypted PDFs.

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

[](#installation)

```
composer require dragonofmercy/phppdf
```

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

[](#quick-start)

```
use DragonOfMercy\PhpPdf\Document;

$pdf = new Document();
$pdf->addPage();
$pdf->save('out.pdf');
```

`$pdf->output()` returns the PDF bytes as a string instead of writing to disk.

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

[](#documentation)

Full usage documentation lives in the [wiki](https://github.com/dragonofmercy/php-pdf/wiki):

- [Getting Started](https://github.com/dragonofmercy/php-pdf/wiki/Getting-Started), [Examples](https://github.com/dragonofmercy/php-pdf/wiki/Examples)
- [Text and Fonts](https://github.com/dragonofmercy/php-pdf/wiki/Text-and-Fonts), [Cells](https://github.com/dragonofmercy/php-pdf/wiki/Cells), [Tables](https://github.com/dragonofmercy/php-pdf/wiki/Tables), [Graphics](https://github.com/dragonofmercy/php-pdf/wiki/Graphics), [Images](https://github.com/dragonofmercy/php-pdf/wiki/Images)
- [Barcodes and QR Codes](https://github.com/dragonofmercy/php-pdf/wiki/Barcodes-and-QR-Codes), [SVG Support](https://github.com/dragonofmercy/php-pdf/wiki/SVG-Support)
- [Markdown](https://github.com/dragonofmercy/php-pdf/wiki/Markdown), [Bookmarks and Hyperlinks](https://github.com/dragonofmercy/php-pdf/wiki/Bookmarks-and-Hyperlinks), [Viewer Preferences](https://github.com/dragonofmercy/php-pdf/wiki/Viewer-Preferences), [Metadata and Encryption](https://github.com/dragonofmercy/php-pdf/wiki/Metadata-and-Encryption)
- [Interactive Forms](https://github.com/dragonofmercy/php-pdf/wiki/Interactive-Forms), [Digital Signatures](https://github.com/dragonofmercy/php-pdf/wiki/Digital-Signatures), [PDF/A Conformance](https://github.com/dragonofmercy/php-pdf/wiki/PDF-A-Conformance)
- Internals and contributing: [Architecture](https://github.com/dragonofmercy/php-pdf/wiki/Internals-Architecture), [Contributing](https://github.com/dragonofmercy/php-pdf/wiki/Contributing)

Development
-----------

[](#development)

The library source lives under `build/`. To get started:

```
git clone https://github.com/dragonofmercy/php-pdf.git
cd php-pdf/build
composer install
composer check   # PHPStan (level max) + PHPUnit
```

See the [Contributing](https://github.com/dragonofmercy/php-pdf/wiki/Contributing) wiki page for coding conventions, golden fixture workflow, and how to add new features.

License
-------

[](#license)

MIT - see [LICENSE](LICENSE).

Support
-------

[](#support)

If this project helps to increase your productivity, you can give me a cup of coffee :)

[![Donate](https://camo.githubusercontent.com/2df914a0101385fd5196ed05218772a0e5f8211fd309ee00367069b730a06b7d/68747470733a2f2f63646e2e6b6f2d66692e636f6d2f63646e2f6b6f6669322e706e673f763d33)](https://ko-fi.com/dragonofmercy)

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance92

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

15

Last Release

28d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/196e1196b041461d3992389e5b7d2d6aa2d06fc7c3acaab9a2007b642d08fa2d?d=identicon)[dragonofmercy](/maintainers/dragonofmercy)

---

Top Contributors

[![dragonofmercy](https://avatars.githubusercontent.com/u/140013?v=4)](https://github.com/dragonofmercy "dragonofmercy (830 commits)")

---

Tags

lib-pdfpdfpdf-generatorphp-pdfpdfpdf-writerpdf-generation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dragonofmercy-phppdf/health.svg)

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k99.4M403](/packages/barryvdh-laravel-dompdf)[tecnickcom/tcpdf

Deprecated legacy PDF engine for PHP. Use instead tecnickcom/tc-lib-pdf.

4.5k109.8M593](/packages/tecnickcom-tcpdf)[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k83.4M582](/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.5k72.4M62](/packages/knplabs-knp-snappy)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k36.7M172](/packages/spatie-browsershot)[smalot/pdfparser

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

2.7k40.5M287](/packages/smalot-pdfparser)

PHPackages © 2026

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