Design Philosophy
TCPDF-Next is inspired by TCPDF but is a complete ground-up rewrite for the modern PHP era. It is not a fork, not an incremental upgrade — it is an entirely new library built on next-generation architecture.
The original TCPDF served the PHP community well for over a decade. But its single-file, 30,000-line architecture cannot support the demands of modern PDF generation: PDF 2.0 compliance, PAdES digital signatures, PDF/A-4 archival, or integration with frameworks like Laravel.
TCPDF-Next keeps the concepts PHP developers know — addPage(), cell(), setFont() — while rebuilding everything underneath to meet 2026 standards.
At a Glance
| Original TCPDF | TCPDF-Next | |
|---|---|---|
| PHP version | 5.x – 8.x | 8.5+ only |
| PDF spec | 1.4 – 1.7 | 2.0 (ISO 32000-2:2020) |
| Architecture | Single ~30K-line class | 213 files, 26 modules, 12 composable traits |
| Type safety | None | PHPStan level 8, backed enums, readonly classes |
| Signatures | Basic PKCS#7 | PAdES B-B (Core) → B-LTA (Pro) |
| Archival | PDF/A-1b (partial) | PDF/A-4 (ISO 19005-4:2020) |
| HTML rendering | Built-in (limited CSS) | Built-in + Chrome CDP (full CSS3) |
| Testing | ~50 tests | 908+ tests, 28,881+ assertions |
| Extensibility | Subclass monolith | Modular ecosystem + extension API |
Ecosystem Architecture
TCPDF-Next is not a monolith. It is a modular ecosystem of four packages, each with a clear responsibility:
Core
Chrome CDP
Framework
Enterprise
- Core (148 files) — The PDF engine. Everything you need for document generation, typography, barcodes, encryption, and PAdES B-B signatures.
- Artisan (17 files) — Chrome CDP integration for pixel-perfect HTML/CSS3 rendering. Text-selectable PDF output via Form XObjects, not rasterized images.
- Laravel (4 files) — Zero-config framework integration. Facade, HTTP responses, queue jobs, Octane-safe bindings.
- Pro (47 files) — Enterprise features. PAdES B-T through B-LTA, PDF/A-4, HSM signing, specialty barcodes.
The extension API is open: third-party developers can build their own extensions that hook into Core through the published interfaces (PdfDocumentInterface, SignerInterface, FontManagerInterface, HsmSignerInterface).
The 12 Composable Traits
The Document class is the single entry point. Instead of a monolithic class, its functionality is composed from 12 focused traits:
| Trait | Responsibility |
|---|---|
HasMetadata | Title, author, subject, keywords, language |
HasPages | Page management, sizes, margins, page groups |
HasTypography | Font loading, sizes, text decorations, RTL, BiDi |
HasColors | RGB, CMYK, spot colors, alpha, blend modes |
HasTextOutput | cell(), multiCell(), text(), write(), writeHtml() |
HasDrawing | Shapes, gradients, patterns, SVG, EPS, images |
HasTransforms | Scale, rotate, translate, skew, mirror |
HasLayout | Headers, footers, columns, booklet |
HasNavigation | Bookmarks, links, TOC, annotations, file attachments |
HasInteractive | Form fields, layers, templates, JavaScript |
HasSecurity | Encryption, digital signatures, tagged PDF, BiDi, linearization |
HasOutput | output(), save(), getPdfData(), streaming |
Every public method returns static for fluent chaining:
$pdf = Document::create()
->setTitle('Invoice') // HasMetadata
->addPage() // HasPages
->setFont('Helvetica', '', 12) // HasTypography
->setFillColor(240, 240, 240) // HasColors
->cell(0, 10, 'Hello') // HasTextOutput
->save('invoice.pdf'); // HasOutputWhat's Next
- Architecture Deep Dive — Namespace map, module boundaries, lazy initialization
- Building Extensions — How to build third-party extensions
- Why PHP 8.5+? — The deliberate choice and Docker guidance