PHPackages                             dskripchenko/php-pdf - 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. dskripchenko/php-pdf

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

dskripchenko/php-pdf
====================

Pure-PHP, MIT-licensed PDF toolkit: generate (HTML/CSS input, fluent builders, low-level emission, 16 barcode formats, 8 chart types, TTF embedding, AcroForm, PKCS#7 signing, PDF/A and PDF/X), plus read and merge existing PDFs (append/reorder pages, stamp overlays, FPDI-style import, encrypted input).

v1.1.0(3w ago)182MITPHPPHP ^8.2CI passing

Since May 15Pushed 3w agoCompare

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

READMEChangelog (1)Dependencies (4)Versions (3)Used By (2)

   ![php-pdf](docs/assets/logo-light.svg)

dskripchenko/php-pdf
====================

[](#dskripchenkophp-pdf)

> Pure-PHP, **MIT-licensed** PDF toolkit — **generate, read, and merge** PDFs. A drop-in alternative for `mpdf/mpdf` (GPL-2.0) and the FPDI add-on (proprietary) — no licensing friction for OEM, on-premise installers, or proprietary bundles.

[![Tests](https://camo.githubusercontent.com/b7dc46c123d4545c6cbeba6ab260a6c1bf27c4b23170562f26f28e0b745ec96e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64736b7269706368656e6b6f2f7068702d7064662f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473266c6f676f3d676974687562)](https://github.com/dskripchenko/php-pdf/actions/workflows/tests.yml)[![Latest Version](https://camo.githubusercontent.com/439b48a2f9e261b6105196d07ec34a6009a4a842cb7f7113da0d70e09af4b964/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64736b7269706368656e6b6f2f7068702d7064663f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/dskripchenko/php-pdf)[![Total Downloads](https://camo.githubusercontent.com/259912db960a58f51dcd2bde9e30037f74026fa72047feffa1816e9803097277/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64736b7269706368656e6b6f2f7068702d706466)](https://packagist.org/packages/dskripchenko/php-pdf)[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/789befc8d88593153c7b6252f5256360c9532b26eb84fcb39b1ab842cc239e9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d707572706c652e737667)](https://www.php.net)

🌐 [Русский](docs/ru/README.md) · [中文](docs/zh/README.md) · [Deutsch](docs/de/README.md) · [English](docs/en/README.md)

---

Contents
--------

[](#contents)

- [Why this library](#why-this-library)
- [Installation](#installation)
- [Quick start](#quick-start)
- [Feature highlights](#feature-highlights)
- [Documentation](#documentation)
- [Performance](#performance)
- [Requirements](#requirements)
- [Testing](#testing)
- [License](#license)

---

Why this library
----------------

[](#why-this-library)

**Licensing.** MIT is the most permissive PHP license — use the code anywhere, including closed-source products. Compare with the main PHP PDF stack:

LibraryLicenseOEM / proprietary bundle**dskripchenko/php-pdf****MIT**✅ no frictionmpdf/mpdfGPL-2.0-only❌ requires GPL bundle or commercial licensetecnickcom/tcpdfLGPL-2.1+⚠️ static-linking nuancesdompdf/dompdfLGPL-2.1⚠️ same as tcpdfsetasign/fpdfre-licensable✅ but extras are proprietary**Engineering.**

- **Modern PHP 8.2+** — readonly classes, enums, named arguments, strict types. Clean, type-safe API surface.
- **Two-layer design** — `Pdf\Document` for low-level emission, `Build\*`fluent builders for high-level documents, `Document::fromHtml()` for HTML/CSS input.
- **Strong typography** — Knuth–Plass line breaking, TTF subsetting with kerning, GSUB ligatures, ToUnicode CMaps, variable font instances, Bidi (UAX#9), Arabic shaping, basic Indic shaping, vertical writing.
- **Widest barcode coverage** — 12 linear + 4 2D formats including rare Pharmacode, MSI Plessey, ITF-14, EAN-2/5 add-ons.
- **Production cryptography** — RC4-128, AES-128, AES-256 (V5 R5 and R6 per ISO 32000-2 / PDF 2.0).
- **PKCS#7 detached signing** with placeholder /ByteRange auto-patching.
- **PDF/A-1a / 1b / 2u and PDF/X-1a / 3 / 4** conformance with embedded sRGB ICC profile and XMP metadata.
- **Tagged PDF / PDF/UA-ready** structure tree with H1–H6, Table/TR/TD, L/LI, custom RoleMap, ParentTree number tree.
- **Streaming output** to a stream resource for large documents.
- **XRef streams** (PDF 1.5+) and Object Streams for compact output.

---

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

[](#installation)

```
composer require dskripchenko/php-pdf
```

PHP 8.2 or later. Required extensions: `mbstring`, `zlib`, `dom`. Add `openssl` for AES encryption or PKCS#7 signing.

---

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

[](#quick-start)

### HTML → PDF

[](#html--pdf)

```
use Dskripchenko\PhpPdf\Document;

$doc = Document::fromHtml(heading(1, 'Quarterly report')
    ->paragraph('Q1 revenue exceeded the forecast by 12%.')
    ->table(function (TableBuilder $t) {
        $t->headerRow(fn (RowBuilder $r) => $r->cells(['Quarter', 'Revenue']));
        $t->row(fn (RowBuilder $r) => $r->cells(['Q1', '$330,000']));
        $t->row(fn (RowBuilder $r) => $r->cells(['Q2', '$310,000']));
    })
    ->toFile('report.pdf');
```

### Low-level emission

[](#low-level-emission)

```
use Dskripchenko\PhpPdf\Pdf\Document;
use Dskripchenko\PhpPdf\Pdf\StandardFont;
use Dskripchenko\PhpPdf\Style\PaperSize;

$doc  = Document::new(PaperSize::A4);
$page = $doc->addPage();
$page->showText('Hello, world!', 72, 720, StandardFont::TimesRoman, 12);
file_put_contents('hello.pdf', $doc->toBytes());
```

---

Feature highlights
------------------

[](#feature-highlights)

### Input

[](#input)

- HTML5 subset parser via `Document::fromHtml()`.
- Block tags ``, ``–``, ``/``/``, tables (with ``/``/`` and ``), ``, ``, ``, ``/``/``.
- Inline tags ``/``, ``/``, ``, ``/``, ``/``, ``, ``, ``, plus ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``, ``.
- HTML5 semantic blocks (``, ``, ``, ``, ``, etc.) and legacy `` / ``.
- Inline CSS: color, background, font properties, text-align, text-decoration, text-transform, margin/padding shorthand, borders, line-height, text-indent.

### Layout and typography

[](#layout-and-typography)

- Knuth–Plass box–glue–penalty line breaker with adaptive penalty.
- Multi-column layout (`ColumnSet`) with column-first flow.
- Tables with rowspan, colspan, border collapse, double borders, border radius, cell padding.
- Headers, footers, watermarks (text and image), section breaks.
- Footnotes with page-bottom positioning.

### Fonts

[](#fonts)

- 14 Adobe base-14 fonts (WinAnsi).
- TTF embedding with on-demand subsetting (CFF and TrueType).
- Kerning, basic GSUB ligatures, ToUnicode CMap.
- Variable font instances (fvar, gvar, MVAR, HVAR, avar).
- Bidi (UAX#9), Arabic shaping, basic Indic shaping.

### Barcodes

[](#barcodes)

- Linear: Code 128 (A/B/C auto, GS1-128), Code 39, Code 93, Code 11, Codabar, ITF/ITF-14, MSI Plessey, Pharmacode, EAN-13/EAN-8 with 2/5- digit add-ons, UPC-A, UPC-E.
- 2D: QR V1–V10 (Numeric, Alphanumeric, Byte, Kanji, ECI, Structured Append, FNC1), Data Matrix ECC 200 (all sizes incl. 144×144, rectangular, 6 modes), PDF417 (Byte/Text/Numeric, Macro, GS1, ECI), Aztec Compact 1–4L + Full 5–32L (Structured Append, FLG/ECI).
- QR convenience factories: vCard 3.0, WiFi Joinware, mailto.

### Charts

[](#charts)

- BarChart, LineChart, PieChart, AreaChart, DonutChart, GroupedBarChart, StackedBarChart, MultiLineChart, ScatterChart.

### Interactive

[](#interactive)

- AcroForm widgets: text (single / multiline / password), checkbox, radio, combo, list, push / submit / reset buttons, signature.
- Per-field JavaScript actions (keystroke, validate, calculate, format).
- Markup annotations: Text, Highlight, Underline, StrikeOut, FreeText, Square, Circle, Line, Stamp, Ink, Polygon, PolyLine.

### Security and conformance

[](#security-and-conformance)

- Encryption: RC4-128, AES-128, AES-256 (V5 R5 + R6 / PDF 2.0).
- PKCS#7 detached signing with timestamp, reason, location, signer name.
- PDF/A-1a, PDF/A-1b, PDF/A-2u with embedded sRGB ICC.
- PDF/X-1a, PDF/X-3, PDF/X-4 with /OutputIntent /S /GTS\_PDFX.
- Tagged PDF / PDF/UA-ready structure tree.

### Reading and merging

[](#reading-and-merging)

- Read existing PDFs (`ReaderDocument`) — classic and stream xref, object streams, corrupt-xref recovery, decryption (RC4 / AES-128 / AES-256).
- Merge (`PdfMerger`) — append and reorder whole or selected pages from multiple files; page annotations and bookmarks carried over with internal links and named destinations remapped.
- Stamp overlays (watermarks, letterheads) and FPDI-style page import into a freshly generated document via `PageImporter::intoDocument()`.
- See the [reading &amp; merging guide](docs/en/MERGE.md).

A complete usage walkthrough is in [docs/en/USAGE.md](docs/en/USAGE.md).

---

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

[](#documentation)

- 📖 [Usage guide](docs/en/USAGE.md) — paragraphs, tables, charts, barcodes, forms, encryption, signing, PDF/A.
- 🔗 [Reading &amp; merging PDFs](docs/en/MERGE.md) — read existing files, append/reorder pages, stamp overlays, handle encrypted input.
- ⚖️ [Comparison vs mpdf / tcpdf / dompdf / FPDF](docs/en/COMPARISON.md) — feature matrix, when to choose each.
- 📊 [Benchmarks](docs/en/BENCHMARKS.md) — reproducible wall-time, memory, and output-size measurements.

---

Performance
-----------

[](#performance)

Median of 5 isolated subprocess runs on macOS 25 / PHP 8.4. Full methodology and reproducer in [docs/en/BENCHMARKS.md](docs/en/BENCHMARKS.md).

Scenariodskripchenko/php-pdfmpdftcpdfdompdfFPDFHTML → PDF article (~5 pages)**10.8 ms**61.1 ms36.1 ms46.9 ms*n/a*100-page invoice (50 rows/page)**518 ms**2367 ms1349 ms8891 ms26 msImage grid (20 pages × 4)**6.4 ms**35.9 ms15.3 ms30.4 ms1.0 msHello world (1 page)4.6 ms29.8 ms14.8 ms12.0 ms0.9 msFPDF wins on the simplest scenarios (no HTML, no wrapping, no table flow), but it cannot generate HTML→PDF and lacks UTF-8, charts, barcodes, forms, encryption, signing.

---

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

[](#requirements)

- PHP **8.2** or later.
- Required: `ext-mbstring`, `ext-zlib`, `ext-dom`.
- Optional: `ext-openssl` (AES encryption and PKCS#7 signing).
- No external binaries — pure PHP.

---

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

2,000+ tests, ~119k assertions, all passing on PHP 8.2 / 8.3 / 8.4 (see the [tests workflow](https://github.com/dskripchenko/php-pdf/actions/workflows/tests.yml)).

---

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

Copyright © 2026 Denis Skripchenko.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance95

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

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 ~47 days

Total

2

Last Release

23d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3aae29ece4986be5d3eea1ba57457547d2ce92fcdee466af45f69ec4079ec9c7?d=identicon)[dskripchenko](/maintainers/dskripchenko)

---

Top Contributors

[![dskripchenko](https://avatars.githubusercontent.com/u/5102028?v=4)](https://github.com/dskripchenko "dskripchenko (339 commits)")

---

Tags

acroformbarcodedigital-signaturefpdifpdi-alternativehtml-to-pdfmpdf-alternativepdfpdf-apdf-generatorpdf-mergerpdf-readerpdf-xphppkcs7pure-phpqrcodetagged-pdfqr codepdffpdibarcodepkcs7pdf-writerpdf mergehtml-to-pdfPDF Readerpdf-apdf-xAcroFormtagged-pdfttf-embed

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dskripchenko-php-pdf/health.svg)

```
[![Health](https://phpackages.com/badges/dskripchenko-php-pdf/health.svg)](https://phpackages.com/packages/dskripchenko-php-pdf)
```

###  Alternatives

[setasign/fpdi

FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.

1.2k155.8M297](/packages/setasign-fpdi)[rockett/weasyprint

A feature-rich WeasyPrint wrapper for generating PDFs from HTML and CSS, with support for PDF/A, PDF/UA, attachments, and optional Laravel integration.

30224.7k](/packages/rockett-weasyprint)[setasign/fpdi-protection

A FPDI compatible version of the FPDF\_Protection script.

324.4M2](/packages/setasign-fpdi-protection)[imal-h/pdf-box

The most advanced, driver-based PDF manipulation library for PHP v3.0. Supports Ghostscript, Chrome Headless (HTML to PDF), OpenSSL/FPDI (Signing), and PDFtk (Forms).

60415.9k](/packages/imal-h-pdf-box)[bithost-gmbh/pdfviewhelpers

This is a TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.

45262.7k3](/packages/bithost-gmbh-pdfviewhelpers)[omaralalwi/gpdf

Custom PDF wrapper supporting Arabic language

15521.6k](/packages/omaralalwi-gpdf)

PHPackages © 2026

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