Adaptation Paket
The Adaptation package provides a drop-in backward-compatible adapter for TCPDF 6.2.13. It maps 252 legacy methods to TCPDF-Next's modern API, allowing existing TCPDF codebases to migrate with minimal code changes.
When to Use Adaptation
| Scenario | Recommendation |
|---|---|
| Existing TCPDF codebase (hundreds of calls) | Use Adaptation — migrate incrementally |
| New project starting from scratch | Use Core directly — cleaner API |
Overriding Header() / Footer() | Use Adaptation — non-final class supports overrides |
| Legacy helper classes in use | Use Adaptation — provides TCPDF_STATIC, TCPDF_FONTS, etc. |
Installationation
bash
composer require yeeefang/tcpdf-next-adaptationAnforderungen: yeeefang/tcpdf-next ^1.7
Quick Start
Replace your TCPDF import and your code works as-is:
php
// Before (legacy TCPDF)
// use TCPDF;
// After (TCPDF-Next Adaptation)
use Yeeefang\TcpdfNext\Adaptation\TCPDF;
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8');
$pdf->SetCreator('My App');
$pdf->SetAuthor('Author');
$pdf->SetTitle('Document');
$pdf->AddPage();
$pdf->SetFont('helvetica', '', 12);
$pdf->Cell(0, 10, 'Hello World', 0, 1);
$pdf->Output('/path/to/output.pdf', 'F');Mapped Methods
The adapter maps 252 legacy TCPDF methods to their TCPDF-Next equivalents, including:
| Legacy Method | TCPDF-Next Equivalent |
|---|---|
SetFont() | setFont() |
Cell() | cell() |
MultiCell() | multiCell() |
writeHTML() | writeHtml() |
Image() | image() |
Ausgabe() | output() |
SetProtection() | setProtection() |
setSignature() | setSignature() |
Header / Footer Overrides
The TCPDF adapter class is non-final, so you can override Header() and Footer() just like legacy TCPDF:
php
class MyPdf extends TCPDF
{
public function Header(): void
{
$this->SetFont('helvetica', 'B', 12);
$this->Cell(0, 10, 'My Header', 0, 1, 'C');
}
public function Footer(): void
{
$this->SetY(-15);
$this->SetFont('helvetica', 'I', 8);
$this->Cell(0, 10, 'Page ' . $this->getAliasNumPage(), 0, 0, 'C');
}
}Legacy Helper Classes
For codebases that reference TCPDF's static helper classes:
| Legacy Class | Adaptation Equivalent |
|---|---|
TCPDF_STATIC | Yeeefang\TcpdfNext\Adaptation\TCPDF_STATIC |
TCPDF_FONTS | Yeeefang\TcpdfNext\Adaptation\TCPDF_FONTS |
TCPDF_COLORS | Yeeefang\TcpdfNext\Adaptation\TCPDF_COLORS |
TCPDF_IMAGES | Yeeefang\TcpdfNext\Adaptation\TCPDF_IMAGES |
Migration Strategy
- Installation the Adaptation package alongside your existing code
- Change the
usestatement fromTCPDFtoYeeefang\TcpdfNext\Adaptation\TCPDF - Run your existing tests — they should pass without changes
- Gradually migrate to the modern fluent API where convenient
- Once fully migrated, remove the Adaptation package and use Core directly