tc-lib-pdf is the new generation of TCPDF for modern PHP. Generate production PDFs in pure PHP 8.2+ with a modular, Composer-first architecture built for maintainability and long-term evolution.
TCPDF started in 2002 and became one of the most widely adopted PDF engines in the PHP ecosystem.
Today, active development continues in tc-lib-pdf and the tc-lib package stack.
IMPORTANT: Maintaining a project for decades that has been installed hundreds of millions of times takes sustained engineering effort, testing, and support. If this project is useful to you, please consider supporting ongoing development via GitHub Sponsors.
Table of contents
Start Here
- Install:
composer require tecnickcom/tc-lib-pdf
- GitHub: https://github.com/tecnickcom/tc-lib-pdf
- API docs: /docs/srcdoc/tc-lib-pdf
- Examples: /examples/
- Packagist: https://packagist.org/packages/tecnickcom/tc-lib-pdf
Why tc-lib-pdf
tc-lib-pdf is a deterministic, pure-PHP PDF toolkit with no external rendering service requirements.
It modernizes the original TCPDF approach into focused packages, stricter typing, and cleaner integration boundaries.
- Modern baseline: PHP 8.2+, Composer-first, modular dependencies.
- Production features: advanced typography, graphics, security, standards, and forms.
- Predictable output: deterministic generation suitable for invoices, reports, labels, and archival workflows.
- Flexible adoption: use the full stack or install only the tc-lib packages your project needs.
Legacy TCPDF vs New tc-lib-pdf
The legacy TCPDF repository is deprecated:
- Legacy library: https://github.com/tecnickcom/TCPDF
- New library: https://github.com/tecnickcom/tc-lib-pdf
Recommendation:
- Starting a new project: use tc-lib-pdf.
- Running legacy TCPDF in production: keep it stable short-term and plan phased migration.
Migration matters because tc-lib-pdf is where active evolution continues.
For TCPDF Users
If you already know TCPDF, tc-lib-pdf will feel familiar in purpose but it is not positioned as a drop-in replacement.
- The codebase is split across focused Composer packages instead of a single monolithic distribution.
- The API surface is more strongly typed and organized around companion services such as fonts, pages, graphics, and images.
- Setup is Composer-first, which means asset preparation such as font generation is part of project bootstrap rather than an implicit bundled step.
The fastest way to evaluate the library is to follow the installation and font setup steps below, then compare runnable examples with the equivalent workflows you already maintain in TCPDF.
Requirements
- PHP 8.2 or later
- Required PHP extensions:
date,pcre(enforced by Composer) - Composer
Optional PHP extensions for extended functionality: gd, zlib.
Feature-specific prerequisites:
- Digital signatures, timestamps, and LTV workflows require signing certificates/keys and any external TSA or revocation endpoints your configuration references.
make preflightdepends on external validation tools when you want standards validation beyond the built-in sample generation.
Installation
For a clean first run:
- Install the package with Composer.
- Generate the companion font files.
- Run the minimal script using the generated
K_PATH_FONTSpath.
composer require tecnickcom/tc-lib-pdf
Or add to your composer.json:
{
"require": {
"tecnickcom/tc-lib-pdf": "^8"
}
}
Font Setup
Font generation is required before the bundled and companion fonts can be used. The detailed workflow now lives on /docs/fonts/, including Composer hooks, manual generation, custom font import, and licensing notes.
For the common case, add this hook to your consuming project’s composer.json:
{
"scripts": {
"tc-lib-pdf-fonts": [
"[ -d vendor/tecnickcom/tc-lib-pdf-font ] && make -C vendor/tecnickcom/tc-lib-pdf-font deps fonts || true"
],
"post-install-cmd": [
"@tc-lib-pdf-fonts"
],
"post-update-cmd": [
"@tc-lib-pdf-fonts"
],
"post-autoload-dump": [
"@tc-lib-pdf-fonts"
]
}
}
To build fonts manually from the project root:
make -C vendor/tecnickcom/tc-lib-pdf-font deps fonts
Quick Start
The following example assumes the script lives in your project root. If you place it elsewhere, adjust the autoload.php and K_PATH_FONTS paths accordingly.
<?php
require(__DIR__ . '/vendor/autoload.php');
\define('K_PATH_FONTS', \realpath(__DIR__ . '/vendor/tecnickcom/tc-lib-pdf-font/target/fonts'));
$pdf = new \Com\Tecnick\Pdf\Tcpdf();
$bfont = $pdf->font->insert($pdf->pon, 'helvetica', '', 12);
$page = $pdf->addPage();
$pdf->page->addContent($bfont['out']);
$html = '<h1>Hello, PDF!</h1><p>Generated with tc-lib-pdf.</p>';
$pdf->addHTMLCell(
html: $html,
posx: 15,
posy: 20,
width: 180,
);
$rawpdf = $pdf->getOutPDFString();
$pdf->renderPDF($rawpdf);
getOutPDFString() returns the raw PDF bytes. renderPDF() streams those bytes to the browser.
If the minimal example fails on first run, verify these two points first:
K_PATH_FONTSresolves to an existing generated font directory.- The companion fonts were generated after
composer installorcomposer update.
For more complete examples, see /examples/.
What You Can Build
- Invoices, receipts, and financial statements
- Shipping labels and barcode-driven logistics documents
- Compliance and archival PDFs, including PDF/A workflows
- Branded reports with custom fonts, SVG, and advanced layout controls
- Interactive documents with forms, annotations, and signatures
Key Capabilities
- Typography and fonts: Unicode, RTL, subsetting, custom fonts, and font tooling. See /docs/fonts/.
- Secure and network-aware integrations: host allowlists and transport controls for remote assets. See /docs/remote-resources/.
- Signature workflows: detached CMS signatures, TSA timestamps, and LTV material. See /docs/digital-signatures/.
- Standards modes: PDF/A, PDF/X, and PDF/UA conformance. See /docs/standards/.
- PDF reuse: import and place pages from existing PDFs. See /docs/pdf-import/.
- Build and packaging workflow: QA, preflight, RPM, and DEB targets. See /docs/development/.
In-Depth Guides
- /docs/fonts/ for font setup, custom font import, and third-party font licensing.
- /docs/development/ for local development, QA, preflight, and packaging.
- /docs/remote-resources/ for host allowlists and
fileOptions. - /docs/digital-signatures/ for signing, timestamping, and LTV workflows.
- /docs/standards/ for PDF/A, PDF/X, and PDF/UA modes.
- /docs/pdf-import/ for source registration, import placement, append workflows, and limitations.
- /docs/srcdoc/tc-lib-pdf for generated API reference.
tc-lib-* Ecosystem
tc-lib-pdf is built on a set of focused, independently versioned packages. Each can be used standalone or as part of the full stack:
- tc-lib-pdf : Top-level PDF generation library; composes the full package stack.
- tc-lib-barcode : Generates 1D and 2D barcodes.
- tc-lib-color : Color conversion and management across RGB, CMYK, HSL, and spot color spaces.
- tc-lib-file : File and data-URI helpers used internally for asset loading.
- tc-lib-unicode : Unicode string processing: bidirectional text, normalization, and character utilities.
- tc-lib-unicode-data : Raw Unicode character data tables used by tc-lib-unicode.
- tc-lib-pdf-encrypt : PDF encryption, permissions, and digital signatures.
- tc-lib-pdf-filter : PDF stream filters.
- tc-lib-pdf-font : Font loading, subsetting, and embedding.
- tc-lib-pdf-graph : Vector graphics primitives.
- tc-lib-pdf-image : Image loading and embedding.
- tc-lib-pdf-page : Page geometry, margins, boxes, and page-level attributes.
- tc-lib-pdf-parser : Reads and parses existing PDF files for import or manipulation.
Contributing
Contributions are welcome. Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md before submitting a pull request.
- Fork the repository and create a feature branch.
- Write or update tests for your change.
- Run
make qato ensure the full pipeline passes. - Open a pull request with a clear description of the change.
Security vulnerabilities should be reported according to SECURITY.md.
Contact
Nicola Asuni — info@tecnick.com