Table de mapping API
Cette page fournit un mapping complet de chaque méthode TCPDF couramment utilisée vers son équivalent TCPDF-Next. Utilisez ceci comme référence lors de la migration de code existant.
Configuration de document
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
new TCPDF($orientation, $unit, $format) | PdfDocument::create()->setOrientation(...)->setPageFormat(...)->build() | Params nommés, constructeur fluide |
SetCreator($creator) | ->setCreator($creator) | |
SetAuthor($author) | ->setAuthor($author) | |
SetTitle($title) | ->setTitle($title) | |
SetSubject($subject) | ->setSubject($subject) | |
SetKeywords($keywords) | ->setKeywords([...]) | Tableau au lieu de chaîne séparée par virgules |
SetMargins($left, $top, $right) | ->setMargins(new Margins($left, $right, $top, $bottom)) | Objet de valeur |
SetCellMargins($l, $t, $r, $b) | TextBlock::create()->setPadding(...) | Remplissage par élément |
SetAutoPageBreak($auto, $margin) | ->setAutoPageBreak($auto, bottomMargin: $margin) | Paramètre nommé |
setLanguageArray($lang) | ->setLocale($locale) | Chaîne de locale standard |
setFontSubsetting($enable) | ->getFontManager()->setSubsetting($enable) | |
SetDefaultMonospacedFont($font) | $renderer->setDefaultMonoFont($font) | |
SetDisplayMode($zoom, $layout) | ->setViewerPreferences(zoom: $zoom, layout: $layout) | |
setImageScale($scale) | Non nécessaire | Dimensionnement basé sur DPI |
SetHeaderMargin($margin) | ->setMargins(new Margins(..., header: $margin)) | |
SetFooterMargin($margin) | ->setMargins(new Margins(..., footer: $margin)) | |
setPrintHeader($enable) | Omettre callback onPageHeader() | |
setPrintFooter($enable) | Omettre callback onPageFooter() |
Gestion des pages
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
AddPage($orientation, $format) | $pdf->addPage($format, $orientation) | |
endPage() | Automatique | Implicite au prochain 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) | Positionnement par élément |
GetX() / GetY() | $page->getCursorX() / $page->getCursorY() | |
SetX($x) / SetY($y) | $page->setCursor($x, $y) | |
getBreakMargin() | $page->getBottomMargin() |
Opérations de polices
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
SetFont($family, $style, $size) | $page->setFont($family, size: $size, style: FontStyle::BOLD) | Enum pour style |
SetFontSize($size) | $page->setFont(..., size: $size) | |
addTTFfont($fontfile) | $pdf->getFontManager()->registerFont($path, $name) | TTF/OTF standard |
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) |
Sortie de texte
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
Cell($w, $h, $txt, $border, $ln, $align) | $page->addText($txt)->setSize($w, $h)->setAlignment(...) | API fluide |
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) | Analyseur basé sur DOM |
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)) | Objet de valeur |
SetTextColorArray($color) | ->setColor(Color::fromArray($color)) |
Images
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
Image($file, $x, $y, $w, $h, $type) | $page->addImage($file)->setPosition($x,$y)->setSize($w,$h) | Détecte automatiquement le format |
ImageEps($file, $x, $y, $w, $h) | $page->addImage($file)->setPosition($x,$y)->setSize($w,$h) | API unifiée |
ImageSVG($file, $x, $y, $w, $h) | $page->addImage($file)->setPosition($x,$y)->setSize($w,$h) | API unifiée |
setImageBuffer($image, $data) | $page->addImage($binaryData, format: $fmt) | |
setJPEGQuality($quality) | ImagePolicy::create()->setJpegQuality($quality) |
Dessin et graphiques
| TCPDF Legacy | 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() ou ->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
| TCPDF Legacy | 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) |
Liens et signets
| TCPDF Legacy | 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) |
Codes-barres
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
write1DBarcode($code, $type, ...) | $page->addBarcode(BarcodeFactory::$type($code))->setPosition(...) | Factory type-safe |
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(...) |
Chiffrement et sécurité
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
SetProtection($perms, $uPass, $oPass, $mode) | $pdf->setEncryption()->setPermissions(...)->apply() | AES-256 uniquement |
setSignature($cert, $key, $pass, $extra) | $signer = new PdfSigner($pdf); $signer->setCertificate(...) | Support PAdES complet |
setSignatureAppearance($x, $y, $w, $h) | $signer->setSignatureField(new SignatureField(...)) |
TIP
La méthode setSignature() de TCPDF ne crée que des signatures PKCS#7 basiques. TCPDF-Next supporte PAdES B-B complet à B-LTA avec intégration d'horodatage, intégration OCSP et Document Security Store. Voir PAdES B-LTA.
Sortie
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
Output($name, 'F') | $pdf->save($path) | Sauvegarder vers fichier |
Output($name, 'D') | Réponse framework avec Content-Disposition: attachment | |
Output($name, 'I') | Réponse framework avec Content-Disposition: inline | |
Output($name, 'S') | $pdf->toString() | Retourner comme chaîne binaire |
Output($name, 'FI') | $pdf->save($path) + réponse inline | |
Output($name, 'FD') | $pdf->save($path) + réponse download | |
Output($name, 'E') | base64_encode($pdf->toString()) |
PDF/A et métadonnées
| TCPDF Legacy | TCPDF-Next | Notes |
|---|---|---|
setPDFVersion($version) | Toujours PDF 2.0 | Non configurable |
| Non disponible | ->setPdfALevel(PdfALevel::PDF_A_4) | Nouvelle fonctionnalité |
| Non disponible | ->setPdfALevel(PdfALevel::PDF_A_4F) | Nouvelle fonctionnalité |
setExtraXMP($xmp) | $pdf->getMetadata()->setXmpProperty(...) |
Méthodes sans équivalent direct
Ces méthodes TCPDF legacy sont gérées différemment dans TCPDF-Next :
| TCPDF Legacy | Notes |
|---|---|
setRTL($enable) | Automatique via algorithme Unicode BiDi (UAX #9) |
setTempPath($path) | PdfDocument::create()->setTempDir(...) |
setCellHeightRatio($ratio) | Utiliser hauteur de ligne explicite dans blocs de texte |
setListIndentWidth($width) | CSS padding-left sur listes |
setOpenCell($isopen) | Non applicable (modèle de cellule différent) |
getHTMLUnitToUnits() | Non applicable (conversion d'unité automatique) |
pixelsToUnits($px) | Units::pixelsToMm($px, $dpi) |
unhtmlentities($text) | htmlspecialchars_decode() (PHP natif) |
Lecture complémentaire
- Migration depuis TCPDF — Guide de migration étape par étape
- Référence API — Documentation API complète TCPDF-Next
- FAQ — Questions courantes de migration