Skip to content

Tabela de Mapeamento de API

Esta página fornece um mapeamento abrangente de cada método comumente usado do TCPDF para seu equivalente no TCPDF-Next. Use isto como referência ao migrar código existente.

Configuração do Documento

TCPDF LegadoTCPDF-NextNotas
new TCPDF($orientation, $unit, $format)PdfDocument::create()->setOrientation(...)->setPageFormat(...)->build()Parâmetros nomeados, builder fluente
SetCreator($creator)->setCreator($creator)
SetAuthor($author)->setAuthor($author)
SetTitle($title)->setTitle($title)
SetSubject($subject)->setSubject($subject)
SetKeywords($keywords)->setKeywords([...])Array em vez de string separada por vírgula
SetMargins($left, $top, $right)->setMargins(new Margins($left, $right, $top, $bottom))Value object
SetCellMargins($l, $t, $r, $b)TextBlock::create()->setPadding(...)Padding por elemento
SetAutoPageBreak($auto, $margin)->setAutoPageBreak($auto, bottomMargin: $margin)Parâmetro nomeado
setLanguageArray($lang)->setLocale($locale)String de locale padrão
setFontSubsetting($enable)->getFontManager()->setSubsetting($enable)
SetDefaultMonospacedFont($font)$renderer->setDefaultMonoFont($font)
SetDisplayMode($zoom, $layout)->setViewerPreferences(zoom: $zoom, layout: $layout)
setImageScale($scale)Não necessárioDimensionamento baseado em DPI
SetHeaderMargin($margin)->setMargins(new Margins(..., header: $margin))
SetFooterMargin($margin)->setMargins(new Margins(..., footer: $margin))
setPrintHeader($enable)Omitir callback onPageHeader()
setPrintFooter($enable)Omitir callback onPageFooter()

Gerenciamento de Páginas

TCPDF LegadoTCPDF-NextNotas
AddPage($orientation, $format)$pdf->addPage($format, $orientation)
endPage()AutomáticoImplícito no próximo 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)Posicionamento por elemento
GetX() / GetY()$page->getCursorX() / $page->getCursorY()
SetX($x) / SetY($y)$page->setCursor($x, $y)
getBreakMargin()$page->getBottomMargin()

Operações de Fonte

TCPDF LegadoTCPDF-NextNotas
SetFont($family, $style, $size)$page->setFont($family, size: $size, style: FontStyle::BOLD)Enum para estilo
SetFontSize($size)$page->setFont(..., size: $size)
addTTFfont($fontfile)$pdf->getFontManager()->registerFont($path, $name)TTF/OTF padrão
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)

Saída de Texto

TCPDF LegadoTCPDF-NextNotas
Cell($w, $h, $txt, $border, $ln, $align)$page->addText($txt)->setSize($w, $h)->setAlignment(...)API fluente
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)Parser baseado em 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))Value object
SetTextColorArray($color)->setColor(Color::fromArray($color))

Imagens

TCPDF LegadoTCPDF-NextNotas
Image($file, $x, $y, $w, $h, $type)$page->addImage($file)->setPosition($x,$y)->setSize($w,$h)Detecta formato automaticamente
ImageEps($file, $x, $y, $w, $h)$page->addImage($file)->setPosition($x,$y)->setSize($w,$h)API unificada
ImageSVG($file, $x, $y, $w, $h)$page->addImage($file)->setPosition($x,$y)->setSize($w,$h)API unificada
setImageBuffer($image, $data)$page->addImage($binaryData, format: $fmt)
setJPEGQuality($quality)ImagePolicy::create()->setJpegQuality($quality)

Desenho e Gráficos

TCPDF LegadoTCPDF-NextNotas
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)

Transformações

TCPDF LegadoTCPDF-NextNotas
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)
TCPDF LegadoTCPDF-NextNotas
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)

Códigos de Barras

TCPDF LegadoTCPDF-NextNotas
write1DBarcode($code, $type, ...)$page->addBarcode(BarcodeFactory::$type($code))->setPosition(...)Factory com 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(...)

Criptografia e Segurança

TCPDF LegadoTCPDF-NextNotas
SetProtection($perms, $uPass, $oPass, $mode)$pdf->setEncryption()->setPermissions(...)->apply()Apenas AES-256
setSignature($cert, $key, $pass, $extra)$signer = new PdfSigner($pdf); $signer->setCertificate(...)Suporte PAdES completo
setSignatureAppearance($x, $y, $w, $h)$signer->setSignatureField(new SignatureField(...))

TIP

O setSignature() do TCPDF cria apenas assinaturas PKCS#7 básicas. O TCPDF-Next suporta PAdES completo de B-B até B-LTA com integração de timestamp, incorporação OCSP e Document Security Store. Veja PAdES B-LTA.

Saída

TCPDF LegadoTCPDF-NextNotas
Output($name, 'F')$pdf->save($path)Salvar em arquivo
Output($name, 'D')Resposta do framework com Content-Disposition: attachment
Output($name, 'I')Resposta do framework com Content-Disposition: inline
Output($name, 'S')$pdf->toString()Retornar como string binária
Output($name, 'FI')$pdf->save($path) + resposta inline
Output($name, 'FD')$pdf->save($path) + resposta download
Output($name, 'E')base64_encode($pdf->toString())

PDF/A e Metadados

TCPDF LegadoTCPDF-NextNotas
setPDFVersion($version)Sempre PDF 2.0Não configurável
Não disponível->setPdfALevel(PdfALevel::PDF_A_4)Novo recurso
Não disponível->setPdfALevel(PdfALevel::PDF_A_4F)Novo recurso
setExtraXMP($xmp)$pdf->getMetadata()->setXmpProperty(...)

Métodos Sem Equivalente Direto

Estes métodos legados do TCPDF são tratados diferentemente no TCPDF-Next:

TCPDF LegadoNotas
setRTL($enable)Automático via algoritmo Unicode BiDi (UAX #9)
setTempPath($path)PdfDocument::create()->setTempDir(...)
setCellHeightRatio($ratio)Use altura de linha explícita em blocos de texto
setListIndentWidth($width)CSS padding-left em listas
setOpenCell($isopen)Não aplicável (modelo de cell diferente)
getHTMLUnitToUnits()Não aplicável (conversão automática de unidade)
pixelsToUnits($px)Units::pixelsToMm($px, $dpi)
unhtmlentities($text)htmlspecialchars_decode() (nativo do PHP)

Leitura Adicional

Distribuído sob a licença LGPL-3.0-or-later.