The next generation of TCPDF - a modern, modular PHP library for programmatically generating PDF documents.
💖 Keep TCPDF maintained.
tc-lib-pdfis the actively-developed successor to TCPDF, which is installed 100M+ times across 500+ PHP packages and is now maintenance-only. If your company depends on it, become a sponsor to keep this shared infrastructure secure and maintained. See Sponsors for tiers.
tc-lib-pdf is a pure-PHP library for generating PDF documents.
It is the modern evolution of TCPDF, built around a modular package architecture, a Composer-first workflow, and strict PHP types.
It coordinates companion packages for fonts, images, graphics, pages, filtering, encryption, and digital signatures into a single document-authoring API.
| Namespace | \Com\Tecnick\Pdf |
| Author | Nicola Asuni <[email protected]> |
| License | GNU LGPL v3 - see LICENSE |
| Website | https://tcpdf.org |
| API docs | https://tcpdf.org/docs/srcdoc/tc-lib-pdf |
| Packagist | https://packagist.org/packages/tecnickcom/tc-lib-pdf |
Releases follow Semantic Versioning:
tc-lib-pdf is the actively-developed successor to TCPDF, which is installed 100M+ times across 500+ PHP packages and is now maintenance-only. Sponsoring funds the ongoing security and maintenance work on both.
Your logo here. Be the first company to back the project: become a sponsor →
See SPONSORS.md for sponsorship tiers, how to add your logo, and the logo/content policy. Individual backers are listed in BACKERS.md.
tc-lib-pdf is not a drop-in replacement for TCPDF:
The runnable examples in examples/index.md cover the equivalent of most TCPDF workflows.
setPageTransparencyGroup(): 'auto' (default) emits the page transparency /Group only on pages that use transparency, 'always' emits it on every page, 'never' omits itGD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM, WBMP, TIFF, ICO, PSD, IFF, SWC)fileOptions with host allowlists plus separate internal and markup local-path allowlists for external assetssignature() facade, with configurable appearance fields. Profiles: legacy (ISO 32000-1 adbe.pkcs7.detached), pades-b-b, pades-b-t, pades-b-lt, pades-b-lta (ETSI.CAdES.detached), with RSA or ECDSA keys and sha256/sha384/sha512 digests. Local (private-key) and external/remote (HSM) signing are both supported. The cryptography lives in tc-lib-pdf-sign; see doc/DIGITAL_SIGNATURES.mdid-aa-signatureTimeStampToken attribute, with configurable digest algorithm, policy OID, nonce, timeout, and TLS peer verification. The token is verified and matched against the request before it is embedded/DSS) carrying /VRI, /Certs, /OCSPs, and /CRLs, referenced from the re-emitted document catalogsignature() LTV optionssignature()->upgradeToLta() adds a /Type /DocTimeStamp archive timestamp over the whole document in a further incremental revisionStructTreeRoot / ParentTree), MarkInfo /Marked true, document language (/Lang), DisplayDocTitle true, ActualText for ligatures and special glyphs, figure alt-text tagging, and heading-level clamping to prevent skipped levels; PDF/UA-2 targets PDF 2.0importPage / useImportedPage)addPageFromImport)setImportSourceFile / setImportSourceData)tc-lib-barcodezlib PHP extension, available in every conformance modeOptional PHP extensions: gd, zlib.
Feature-specific prerequisites:
make preflight runs external validation tools when they are installed.K_PATH_FONTS path.composer require tecnickcom/tc-lib-pdf
Or add to your composer.json:
{
"require": {
"tecnickcom/tc-lib-pdf": "^8"
}
}
This example assumes the script lives in the project root; adjust the autoload.php and K_PATH_FONTS paths otherwise.
<?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, // mm from left page edge
posy: 20, // mm from top page edge
width: 180, // mm wide (0 = to right margin)
);
$rawpdf = $pdf->getOutPDFString();
$pdf->renderPDF($rawpdf);
getOutPDFString() returns the raw PDF bytes. renderPDF() streams those bytes to the browser; to store them in a file or send them as an attachment, keep the returned string.
Note:
realpath()returnsfalsewhen the fonts directory does not exist. AK_PATH_FONTSerror on first run means the fonts have not been generated (see doc/FONTS.md).
The examples directory holds runnable scripts for the supported features.
Starting points:
Topic groups:
To run them locally:
make fonts # generate the companion fonts used by the examples
make server # start a local PHP server
Then open http://localhost:8971/E000_overview.php.
Focused guides in the doc/ directory:
fileOptions (allowedHosts, allowedPaths, markupAllowedPaths, cURL policy): doc/REMOTE_RESOURCES.mdCacheInterface, selective caching): doc/CACHE.mdContributions are welcome. Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md before submitting a pull request.
make qa to ensure the full pipeline passes.Security vulnerabilities should be reported according to SECURITY.md.
How can I help you explore Laravel packages today?