tc-lib-pdf is the new generation of TCPDF for modern PHP. Generate production PDFs in pure PHP 8.1+ 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.
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.1+, 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.
Requirements
- PHP 8.1+
- Composer
- Optional extensions:
gd,zlib
Quick Start
<?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();
$font = $pdf->font->insert($pdf->pon, 'helvetica', '', 12);
$pdf->addPage();
$pdf->page->addContent($font['out']);
$html = '<h1>Hello, PDF!</h1><p>Generated with tc-lib-pdf.</p>';
$pdf->addHTMLCell($html, 15, 20, 180);
$raw = $pdf->getOutPDFString();
$pdf->renderPDF($raw);
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 Features
Text and Typography
- Full UTF-8 Unicode and right-to-left language support
- TrueTypeUnicode, OpenTypeUnicode v1, TrueType, OpenType v1, Type1, and CID-0 fonts
- Font subsetting for smaller files
- TeX-style language-aware hyphenation, optional zero-width breakpoints, and tracking controls
- Text rendering modes: fill, stroke, and clipping
- Automatic line breaks, page breaks, and justified text
Layout and Rendering
- Standard and custom page sizes, margins, and measurement units
- HTML and CSS rendering
- SVG rendering
- Multi-column layouts and no-write page regions
- Headers, footers, reusable page content, bookmarks, named destinations, and table of contents
- Automatic page numbering, page groups, page box control, and page reordering
Images and Graphics
- Native JPEG, PNG, and SVG support
- Extended image support through optional GD formats
- Geometric drawing and 2D transformations
- Linear/radial and mesh gradients, crop marks, and registration bars
- ICC profiles, grayscale/RGB/CMYK/spot colors, transparency, and overprint control
Security and Standards
- Password and certificate-based encryption (RC4 and AES up to 256-bit)
- Digital signatures: detached CMS (PKCS#7) signatures with configurable appearance fields
- RFC 3161 TSA timestamps embedded in CMS signatures with configurable digest, policy OID, nonce, timeout, and TLS peer verification
- LTV (Long-Term Validation) embedding in the same PDF revision:
/DSS,/VRI,/OCSPs,/CRLs, and/Certs - Rich annotations: links, notes, attachments, markup, widgets, and media
- JavaScript embedding
- PDF/A (1/2/3 with a/b/u conformance levels) and PDF/X support
Advanced Workflows
- 1D and 2D barcodes through
tc-lib-barcode - Interactive AcroForm fields
- XObject templates and layers with visibility controls
- Multiple output targets: browser display, download, file save, and MIME attachment
- Factur-X / ZUGFeRD workflows via embedded XML in PDF/A-3
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 (QR, Data Matrix, Code 128, and more).
- 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: RC4 and AES (up to 256-bit), permissions, and digital signatures.
- tc-lib-pdf-filter : PDF stream filters: FlateDecode, ASCII85, LZW, and others.
- tc-lib-pdf-font : Font loading, subsetting, and embedding for all supported font types.
- tc-lib-pdf-graph : Vector graphics primitives: paths, transformations, gradients, and transparency.
- tc-lib-pdf-image : Image loading and embedding: JPEG, PNG, SVG, and GD-backed formats.
- 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.
Migration Path
- Keep legacy TCPDF stable in production while planning migration.
- Start new features on
tc-lib-pdf. - Move legacy document flows incrementally: one template, one module, or one service at a time.
- Validate outputs with your existing PDF regression checks.
Next Steps
- Read the documentation
- Explore examples
- Try signature examples: /examples/007_example_signature_basic/, /examples/008_example_signature_timestamp/, /examples/009_example_signature_ltv/
- Browse project packages on /projects/
- View source and contribute on GitHub
If this project helps your work, please consider supporting development via PayPal.