Skip to content

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

ScenarioRecommendation
Existing TCPDF codebase (hundreds of calls)Use Adaptation — migrate incrementally
New project starting from scratchUse Core directly — cleaner API
Overriding Header() / Footer()Use Adaptation — non-final class supports overrides
Legacy helper classes in useUse Adaptation — provides TCPDF_STATIC, TCPDF_FONTS, etc.

Installationation

bash
composer require yeeefang/tcpdf-next-adaptation

Anforderungen: 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 MethodTCPDF-Next Equivalent
SetFont()setFont()
Cell()cell()
MultiCell()multiCell()
writeHTML()writeHtml()
Image()image()
Ausgabe()output()
SetProtection()setProtection()
setSignature()setSignature()

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 ClassAdaptation Equivalent
TCPDF_STATICYeeefang\TcpdfNext\Adaptation\TCPDF_STATIC
TCPDF_FONTSYeeefang\TcpdfNext\Adaptation\TCPDF_FONTS
TCPDF_COLORSYeeefang\TcpdfNext\Adaptation\TCPDF_COLORS
TCPDF_IMAGESYeeefang\TcpdfNext\Adaptation\TCPDF_IMAGES

Migration Strategy

  1. Installation the Adaptation package alongside your existing code
  2. Change the use statement from TCPDF to Yeeefang\TcpdfNext\Adaptation\TCPDF
  3. Run your existing tests — they should pass without changes
  4. Gradually migrate to the modern fluent API where convenient
  5. Once fully migrated, remove the Adaptation package and use Core directly

Veröffentlicht unter der LGPL-3.0-or-later Lizenz.