Skip to content

APIマッピングテーブル

このページでは、一般的に使用されるすべてのTCPDFメソッドとTCPDF-Nextの対応を包括的にマッピングしています。既存コードの移行時のリファレンスとしてご利用ください。

ドキュメント設定

レガシーTCPDFTCPDF-Next備考
new TCPDF($orientation, $unit, $format)PdfDocument::create()->setOrientation(...)->setPageFormat(...)->build()名前付きパラメータ、フルエントビルダー
SetCreator($creator)->setCreator($creator)
SetAuthor($author)->setAuthor($author)
SetTitle($title)->setTitle($title)
SetSubject($subject)->setSubject($subject)
SetKeywords($keywords)->setKeywords([...])カンマ区切り文字列の代わりに配列
SetMargins($left, $top, $right)->setMargins(new Margins($left, $right, $top, $bottom))値オブジェクト
SetCellMargins($l, $t, $r, $b)TextBlock::create()->setPadding(...)要素ごとのパディング
SetAutoPageBreak($auto, $margin)->setAutoPageBreak($auto, bottomMargin: $margin)名前付きパラメータ
setLanguageArray($lang)->setLocale($locale)標準ロケール文字列
setFontSubsetting($enable)->getFontManager()->setSubsetting($enable)
SetDefaultMonospacedFont($font)$renderer->setDefaultMonoFont($font)
SetDisplayMode($zoom, $layout)->setViewerPreferences(zoom: $zoom, layout: $layout)
setImageScale($scale)不要DPIベースのサイズ指定
SetHeaderMargin($margin)->setMargins(new Margins(..., header: $margin))
SetFooterMargin($margin)->setMargins(new Margins(..., footer: $margin))
setPrintHeader($enable)onPageHeader()コールバックを省略
setPrintFooter($enable)onPageFooter()コールバックを省略

ページ管理

レガシーTCPDFTCPDF-Next備考
AddPage($orientation, $format)$pdf->addPage($format, $orientation)
endPage()自動次の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)要素ごとの位置指定
GetX() / GetY()$page->getCursorX() / $page->getCursorY()
SetX($x) / SetY($y)$page->setCursor($x, $y)
getBreakMargin()$page->getBottomMargin()

フォント操作

レガシーTCPDFTCPDF-Next備考
SetFont($family, $style, $size)$page->setFont($family, size: $size, style: FontStyle::BOLD)スタイルにEnum
SetFontSize($size)$page->setFont(..., size: $size)
addTTFfont($fontfile)$pdf->getFontManager()->registerFont($path, $name)標準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)

テキスト出力

レガシーTCPDFTCPDF-Next備考
Cell($w, $h, $txt, $border, $ln, $align)$page->addText($txt)->setSize($w, $h)->setAlignment(...)フルエント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ベースパーサー
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))値オブジェクト
SetTextColorArray($color)->setColor(Color::fromArray($color))

画像

レガシーTCPDFTCPDF-Next備考
Image($file, $x, $y, $w, $h, $type)$page->addImage($file)->setPosition($x,$y)->setSize($w,$h)フォーマット自動検出
ImageEps($file, $x, $y, $w, $h)$page->addImage($file)->setPosition($x,$y)->setSize($w,$h)統一API
ImageSVG($file, $x, $y, $w, $h)$page->addImage($file)->setPosition($x,$y)->setSize($w,$h)統一API
setImageBuffer($image, $data)$page->addImage($binaryData, format: $fmt)
setJPEGQuality($quality)ImagePolicy::create()->setJpegQuality($quality)

描画とグラフィックス

レガシーTCPDFTCPDF-Next備考
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)

変換

レガシーTCPDFTCPDF-Next備考
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)

リンクとブックマーク

レガシーTCPDFTCPDF-Next備考
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)

バーコード

レガシーTCPDFTCPDF-Next備考
write1DBarcode($code, $type, ...)$page->addBarcode(BarcodeFactory::$type($code))->setPosition(...)型安全ファクトリ
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(...)

暗号化とセキュリティ

レガシーTCPDFTCPDF-Next備考
SetProtection($perms, $uPass, $oPass, $mode)$pdf->setEncryption()->setPermissions(...)->apply()AES-256のみ
setSignature($cert, $key, $pass, $extra)$signer = new PdfSigner($pdf); $signer->setCertificate(...)完全なPAdESサポート
setSignatureAppearance($x, $y, $w, $h)$signer->setSignatureField(new SignatureField(...))

TIP

TCPDFのsetSignature()は基本的なPKCS#7署名のみを作成します。TCPDF-Nextはタイムスタンプ統合、OCSP埋め込み、ドキュメントセキュリティストアを含む完全なPAdES B-BからB-LTAをサポートしています。PAdES B-LTAをご覧ください。

出力

レガシーTCPDFTCPDF-Next備考
Output($name, 'F')$pdf->save($path)ファイルに保存
Output($name, 'D')Content-Disposition: attachment付きフレームワークレスポンス
Output($name, 'I')Content-Disposition: inline付きフレームワークレスポンス
Output($name, 'S')$pdf->toString()バイナリ文字列として返却
Output($name, 'FI')$pdf->save($path) + インラインレスポンス
Output($name, 'FD')$pdf->save($path) + ダウンロードレスポンス
Output($name, 'E')base64_encode($pdf->toString())

PDF/Aとメタデータ

レガシーTCPDFTCPDF-Next備考
setPDFVersion($version)常にPDF 2.0設定不可
利用不可->setPdfALevel(PdfALevel::PDF_A_4)新機能
利用不可->setPdfALevel(PdfALevel::PDF_A_4F)新機能
setExtraXMP($xmp)$pdf->getMetadata()->setXmpProperty(...)

直接対応のないメソッド

これらのレガシーTCPDFメソッドは、TCPDF-Nextでは異なる方法で処理されます:

レガシーTCPDF備考
setRTL($enable)Unicode BiDiアルゴリズム(UAX #9)で自動処理
setTempPath($path)PdfDocument::create()->setTempDir(...)
setCellHeightRatio($ratio)テキストブロックで明示的な行高を使用
setListIndentWidth($width)リストのCSS padding-left
setOpenCell($isopen)非該当(異なるセルモデル)
getHTMLUnitToUnits()非該当(自動単位変換)
pixelsToUnits($px)Units::pixelsToMm($px, $dpi)
unhtmlentities($text)htmlspecialchars_decode()(PHP組み込み)

さらに詳しく

LGPL-3.0-or-later ライセンスの下で公開されています。