TCPDF
Pure-PHP library for generating PDF documents, barcodes, and forms with Unicode and RTL support
Repository Health
Technical Analysis
TCPDF is a widely-deployed, pure-PHP library for creating PDF documents directly from application code, with no external binaries or extensions required beyond the standard PHP toolchain. It supports full Unicode and right-to-left text, 1D/2D barcodes (including QR codes, DataMatrix, and PDF417), digital signatures, encryption, and PDF/A and PDF/UA compliance, and it renders HTML/CSS markup into paginated documents via its bundled writeHTML() engine.
As of the current major version, TCPDF is a compatibility facade: its public API (all 291 documented methods) is preserved unchanged, but the actual rendering is delegated internally to the modern tecnickcom/tc-lib-pdf engine. This lets the huge existing base of TCPDF integrations (installed in 100M+ deployments across 500+ PHP packages) keep working without code changes, while benefiting from the newer engine underneath. The project is officially in maintenance-only mode — new projects are directed to tc-lib-pdf — but TCPDF itself continues to receive security and compatibility fixes.
What You Get
- A stateful, cursor-based PDF authoring API (
AddPage(),SetFont(),Cell(),Write(),Image()) that mirrors how you’d lay out a printed page - Built-in HTML/CSS-to-PDF rendering via
writeHTML()for turning existing markup into paginated documents - 1D and 2D barcode generation (Code128, QR, DataMatrix, PDF417, and others) with no external dependencies
- Digital signatures, RC4/AES encryption, and PDF/A & PDF/UA compliance modes for regulated or archival documents
- Full Unicode and right-to-left (Arabic, Hebrew) text support with automatic font subsetting
Common Use Cases
- Generating invoices, receipts, and financial statements from application data
- Producing printable shipping labels and barcodes for logistics and inventory systems
- Converting HTML reports or templates into downloadable, archivable PDF documents
- Issuing digitally signed and PDF/A-compliant documents for legal or regulatory workflows
Under The Hood
Architecture: TCPDF’s current major version is a compatibility facade rather than a self-contained rendering engine: the TCPDF class in tcpdf.php (8,500+ lines) preserves all 291 legacy public method signatures, but each method internally delegates to \Com\Tecnick\Pdf\Tcpdf from the tecnickcom/tc-lib-pdf package, with a thin internal state layer reproducing the legacy stateful cursor/page model (current X/Y, margins, fonts, automatic page breaks). This lets existing call sites (new TCPDF(...), AddPage(), writeHTML()) keep working unchanged while the actual PDF generation, font handling, and image processing happen in the modular tc-lib-* libraries.
Tech Stack: Requires PHP 8.2+ and the ext-curl extension, with tecnickcom/tc-lib-pdf (^8) as a hard Composer dependency rather than an optional add-on. Font assets are supplied by the separate tecnickcom/tc-lib-pdf-font package and discovered under vendor/tecnickcom/tc-lib-pdf-font/target/fonts/, generated via make fonts. Optional ext-gd and ext-imagick extensions widen image-format support.
Code Quality: The test/ directory contains PHPUnit test classes covering cells, colors, fonts, headers/footers, metadata, and page state (TcpdfSmokeTest.php, TcpdfCellTest.php, etc.), run against PHPUnit ^11.5/^12.5/^13.2. A MAPPING.md file documents the delegation status (delegated, adapter, shim, intentional-noop, blocked) for every public method, which is unusually thorough traceability for a facade rewrite of this scope. Resource loading (local files and remote URLs) is sandboxed through explicit allowlist constants (K_ALLOWED_PATHS, K_ALLOWED_HOSTS), a deliberate SSRF mitigation.
API Design: The public API is intentionally unchanged from legacy TCPDF, favoring zero-migration-cost compatibility over modern PHP idioms (no typed value objects, still relies on class constants and stateful setters like SetFont()/SetXY()). This makes it trivial to keep existing integrations running, but developers starting fresh are explicitly steered toward tc-lib-pdf’s cleaner, more modular API instead.
Used by 3 apps in this directory
LimeSurvey
Forms Surveys
The world's most flexible open-source survey platform with 900+ templates, conditional logic, 80+ languages, and full GDPR compliance for any scale.
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.