API Mapping Table
This page provides a comprehensive mapping of every commonly used TCPDF method to its TCPDF-Next equivalent. Use this as a reference when migrating existing code.
Document Setup
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
new TCPDF($orientation, $unit, $format) | PdfDocument::create()->setOrientation(...)->setPageFormat(...)->build() | Named params, fluent builder |
SetCreator($creator) | ->setCreator($creator) | |
SetAuthor($author) | ->setAuthor($author) | |
SetTitle($title) | ->setTitle($title) | |
SetSubject($subject) | ->setSubject($subject) | |
SetKeywords($keywords) | ->setKeywords([...]) | Array instead of comma-separated string |
SetMargins($left, $top, $right) | ->setMargins(new Margins($left, $right, $top, $bottom)) | Value object |
SetCellMargins($l, $t, $r, $b) | TextBlock::create()->setPadding(...) | Per-element padding |
SetAutoPageBreak($auto, $margin) | ->setAutoPageBreak($auto, bottomMargin: $margin) | Named parameter |
setLanguageArray($lang) | ->setLocale($locale) | Standard locale string |
setFontSubsetting($enable) | ->getFontManager()->setSubsetting($enable) | |
SetDefaultMonospacedFont($font) | $renderer->setDefaultMonoFont($font) | |
SetDisplayMode($zoom, $layout) | ->setViewerPreferences(zoom: $zoom, layout: $layout) | |
setImageScale($scale) | Not needed | DPI-based sizing |
SetHeaderMargin($margin) | ->setMargins(new Margins(..., header: $margin)) | |
SetFooterMargin($margin) | ->setMargins(new Margins(..., footer: $margin)) | |
setPrintHeader($enable) | Omit onPageHeader() callback | |
setPrintFooter($enable) | Omit onPageFooter() callback |
Page Management
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
AddPage($orientation, $format) | $pdf->addPage($format, $orientation) | |
endPage() | Automatic | Implicit on next addPage() |
getPage() | $pdf->getCurrentPageNumber() | |
setPage($page) | $pdf->getPage($pageNumber) | |
getNumPages() | $pdf->getPageCount() | |
deletePage($page) | $pdf->removePage($pageNumber) | |
movePage($from, $to) | $pdf->movePage($from, $to) | |
copyPage($page) | $pdf->duplicatePage($pageNumber) | |
lastPage() | $pdf->getPage($pdf->getPageCount()) | |
getPageWidth() | $page->getWidth() | |
getPageHeight() | $page->getHeight() | |
SetXY($x, $y) | ->setPosition($x, $y) | Per-element positioning |
GetX() / GetY() | $page->getCursorX() / $page->getCursorY() | |
SetX($x) / SetY($y) | $page->setCursor($x, $y) | |
getBreakMargin() | $page->getBottomMargin() |
Font Operations
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
SetFont($family, $style, $size) | $page->setFont($family, size: $size, style: FontStyle::BOLD) | Enum for style |
SetFontSize($size) | $page->setFont(..., size: $size) | |
addTTFfont($fontfile) | $pdf->getFontManager()->registerFont($path, $name) | Standard TTF/OTF |
getFontFamilyName() | $page->getCurrentFont()->getFamily() | |
getFontSize() | $page->getCurrentFont()->getSize() | |
getFontSizePt() | $page->getCurrentFont()->getSizeInPoints() | |
isCharDefined($char) | $font->hasGlyph($char) | |
GetStringWidth($string) | $font->measureText($string, $size)->getWidth() | |
GetCharWidth($char) | $font->getGlyphWidth($char, $size) | |
getNumLines($text, $width) | $font->calculateLines($text, $width, $size) |
Text Output
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
Cell($w, $h, $txt, $border, $ln, $align) | $page->addText($txt)->setSize($w, $h)->setAlignment(...) | Fluent API |
MultiCell($w, $h, $txt, $border, $align) | $page->addParagraph($txt)->setWidth($w)->setAlignment(...) | |
Write($h, $txt, $link) | $page->addText($txt)->setLineHeight($h)->setLink($link) | |
writeHTML($html) | $renderer->writeHtml($html) | DOM-based parser |
writeHTMLCell($w, $h, $x, $y, $html) | $renderer->writeHtml($html, position: [$x, $y], width: $w) | |
Text($x, $y, $txt) | $page->addText($txt)->setPosition($x, $y) | |
Ln($h) | $page->advanceCursor($h) | |
SetTextColor($r, $g, $b) | ->setColor(Color::rgb($r, $g, $b)) | Value object |
SetTextColorArray($color) | ->setColor(Color::fromArray($color)) |
Images
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
Image($file, $x, $y, $w, $h, $type) | $page->addImage($file)->setPosition($x,$y)->setSize($w,$h) | Auto-detects format |
ImageEps($file, $x, $y, $w, $h) | $page->addImage($file)->setPosition($x,$y)->setSize($w,$h) | Unified API |
ImageSVG($file, $x, $y, $w, $h) | $page->addImage($file)->setPosition($x,$y)->setSize($w,$h) | Unified API |
setImageBuffer($image, $data) | $page->addImage($binaryData, format: $fmt) | |
setJPEGQuality($quality) | ImagePolicy::create()->setJpegQuality($quality) |
Drawing and Graphics
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
Line($x1, $y1, $x2, $y2) | $canvas->drawLine($x1, $y1, $x2, $y2)->stroke() | |
Rect($x, $y, $w, $h, $style) | $canvas->drawRect($x, $y, $w, $h)->fill() or ->stroke() | |
RoundedRect($x, $y, $w, $h, $r) | $canvas->drawRoundedRect($x, $y, $w, $h, $r) | |
Circle($x, $y, $r) | $canvas->drawCircle($x, $y, $r) | |
Ellipse($x, $y, $rx, $ry) | $canvas->drawEllipse($x, $y, $rx, $ry) | |
Curve($x0,$y0,$x1,$y1,$x2,$y2,$x3,$y3) | $canvas->moveTo($x0,$y0)->curveTo($x1,$y1,$x2,$y2,$x3,$y3) | |
Polygon($points) | $canvas->drawPolygon($points) | |
RegularPolygon($x, $y, $r, $sides) | $canvas->drawRegularPolygon($x, $y, $r, $sides) | |
Arrow($x0, $y0, $x1, $y1) | $canvas->drawArrow($x0, $y0, $x1, $y1) | |
SetDrawColor($r, $g, $b) | $canvas->setStrokeColor(Color::rgb($r, $g, $b)) | |
SetFillColor($r, $g, $b) | $canvas->setFillColor(Color::rgb($r, $g, $b)) | |
SetDrawColorArray($color) | $canvas->setStrokeColor(Color::fromArray($color)) | |
SetFillColorArray($color) | $canvas->setFillColor(Color::fromArray($color)) | |
SetLineWidth($width) | $canvas->setLineWidth($width) | |
SetLineStyle($style) | $canvas->setLineStyle(LineStyle::from($style)) | |
SetAlpha($alpha, $blend) | $canvas->setOpacity($alpha)->setBlendMode($blend) |
Transformations
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
StartTransform() | $canvas->saveState() | |
StopTransform() | $canvas->restoreState() | |
Translate($tx, $ty) | $canvas->translate($tx, $ty) | |
Rotate($angle, $x, $y) | $canvas->rotate($angle, $x, $y) | |
Scale($sx, $sy, $x, $y) | $canvas->scale($sx, $sy, $x, $y) | |
MirrorH($x) | $canvas->scale(-1, 1, $x, 0) | |
MirrorV($y) | $canvas->scale(1, -1, 0, $y) | |
Skew($xAngle, $yAngle) | $canvas->skew($xAngle, $yAngle) |
Links and Bookmarks
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
SetLink($link, $y, $page) | $pdf->createInternalLink($page, $y) | |
AddLink() | $pdf->createLink() | |
Link($x, $y, $w, $h, $link) | $page->addLink($url)->setRect($x, $y, $w, $h) | |
Annotation($x, $y, $w, $h, $text) | $page->addAnnotation($text)->setRect($x, $y, $w, $h) | |
Bookmark($txt, $level) | $pdf->addBookmark($txt, level: $level) |
Barcodes
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
write1DBarcode($code, $type, ...) | $page->addBarcode(BarcodeFactory::$type($code))->setPosition(...) | Type-safe factory |
write2DBarcode($code, 'QRCODE', ...) | $page->addBarcode(BarcodeFactory::qrCode($code))->setPosition(...) | |
write2DBarcode($code, 'DATAMATRIX', ...) | $page->addBarcode(BarcodeFactory::dataMatrix($code))->setPosition(...) | |
write2DBarcode($code, 'PDF417', ...) | $page->addBarcode(BarcodeFactory::pdf417($code))->setPosition(...) |
Encryption and Security
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
SetProtection($perms, $uPass, $oPass, $mode) | $pdf->setEncryption()->setPermissions(...)->apply() | AES-256 only |
setSignature($cert, $key, $pass, $extra) | $signer = new PdfSigner($pdf); $signer->setCertificate(...) | Full PAdES support |
setSignatureAppearance($x, $y, $w, $h) | $signer->setSignatureField(new SignatureField(...)) |
TIP
TCPDF's setSignature() creates only basic PKCS#7 signatures. TCPDF-Next supports full PAdES B-B through B-LTA with timestamp integration, OCSP embedding, and Document Security Store. See PAdES B-LTA.
Output
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
Output($name, 'F') | $pdf->save($path) | Save to file |
Output($name, 'D') | Framework response with Content-Disposition: attachment | |
Output($name, 'I') | Framework response with Content-Disposition: inline | |
Output($name, 'S') | $pdf->toString() | Return as binary string |
Output($name, 'FI') | $pdf->save($path) + inline response | |
Output($name, 'FD') | $pdf->save($path) + download response | |
Output($name, 'E') | base64_encode($pdf->toString()) |
PDF/A and Metadata
| Legacy TCPDF | TCPDF-Next | Notes |
|---|---|---|
setPDFVersion($version) | Always PDF 2.0 | Not configurable |
| Not available | ->setPdfALevel(PdfALevel::PDF_A_4) | New feature |
| Not available | ->setPdfALevel(PdfALevel::PDF_A_4F) | New feature |
setExtraXMP($xmp) | $pdf->getMetadata()->setXmpProperty(...) |
Methods with No Direct Equivalent
These legacy TCPDF methods are handled differently in TCPDF-Next:
| Legacy TCPDF | Notes |
|---|---|
setRTL($enable) | Automatic via Unicode BiDi algorithm (UAX #9) |
setTempPath($path) | PdfDocument::create()->setTempDir(...) |
setCellHeightRatio($ratio) | Use explicit line height in text blocks |
setListIndentWidth($width) | CSS padding-left on lists |
setOpenCell($isopen) | Not applicable (different cell model) |
getHTMLUnitToUnits() | Not applicable (automatic unit conversion) |
pixelsToUnits($px) | Units::pixelsToMm($px, $dpi) |
unhtmlentities($text) | htmlspecialchars_decode() (PHP built-in) |
Further Reading
- Migration from TCPDF — Step-by-step migration guide
- API Reference — Complete TCPDF-Next API documentation
- FAQ — Common migration questions