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 generator: low-level emission, fluent builders, HTML/CSS input, 16 barcode formats, 8 chart types, TTF embedding with kerning and ligatures, AcroForm, PKCS#7 signing, PDF/A and PDF/X conformance.

v1.0.0(3w ago)041MITPHPPHP ^8.2

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 1w ago

READMEChangelogDependencies (2)Versions (2)Used By (1)

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

[](#dskripchenkophp-pdf)

> Pure-PHP, **MIT-licensed** PDF generator. A drop-in alternative for `mpdf/mpdf` (GPL-2.0) — no licensing friction for OEM, on-premise installers, or proprietary bundles.

[![Packagist](https://camo.githubusercontent.com/0a78b7a1ca170630d546984992e87a0b62cb5a75bc166c646307519c5f29b8db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64736b7269706368656e6b6f2f7068702d7064662e737667)](https://packagist.org/packages/dskripchenko/php-pdf)[![License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/962aced9b09d89716dbebf186ff899754a096ff1068b6b7988675c2d9fab9331/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d626c75652e737667)](composer.json)[![Tests](https://camo.githubusercontent.com/7b0c19badf18ef85f796a9d85b2ed75f0e5d4f9ac6aa0194b839c6ea27e8bb97/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d3139373725323070617373696e672d737563636573732e737667)](#testing)

**Languages:** [English](docs/en/README.md) · [Русский](docs/ru/README.md) · [中文](docs/zh/README.md) · [Deutsch](docs/de/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.

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.
- ⚖️ [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
```

1977 tests, ~119k assertions, all passing on PHP 8.2 / 8.3 / 8.4.

---

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

Copyright © 2026 Denis Skripchenko.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance94

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

25d ago

### Community

Maintainers

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

---

Tags

qr codepdfbarcodepkcs7pdf-writerhtml-to-pdfpdf-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

[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.

29217.1k](/packages/rockett-weasyprint)[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).

60410.9k](/packages/imal-h-pdf-box)[cangelis/pdf

Yet another HTML to PDF Converter based on wkhtmltopdf

5964.1k1](/packages/cangelis-pdf)[sarder/pdfstudio

Design, preview, and generate PDFs using HTML, TailwindCSS or Bootstrap in Laravel

1591.2k](/packages/sarder-pdfstudio)[cangelis/l4pdf

Yet another HTML to PDF Converter for Laravel4

548.5k](/packages/cangelis-l4pdf)[yetiforce/yetiforcepdf

Library that generate pdf files from html.

13128.6k1](/packages/yetiforce-yetiforcepdf)

PHPackages © 2026

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