naitsirch/tcpdf-extension
最新稳定版本:v1.2.0
Composer 安装命令:
composer require naitsirch/tcpdf-extension
包简介
This library extends the TCPDF library for example with a smart API for creating tables.
关键字:
README 文档
README
TCPDF is a PHP library to generate PDF documents. It is very feature rich, but not easy to use.
This library builds on top of the TCPDF library. At the current state it provides only a smart API to create tables in a comfortable way.
ABANDONED
This repository is abandoned and should not be used anymore. Please change from naitsirch/tcpdf-extension to the compatible stollr/tcpdf-extension.
Features
- More comfortable creation of tables
Installation
The easiest way to use this library is by installing it via Composer.
Add this to your project's composer.json:
{ "require": { "naitsirch/tcpdf-extension": "dev-master" } } Usage
Creating tables
First you have to create an instance of TCPDF.
use TCPDF; $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf->SetTitle('My PDF file'); $pdf->SetMargins(20, 20, 20); $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); $pdf->SetAutoPageBreak(true, 9); $pdf->SetFont('dejavusans', '', 10);
Please look into the documentation of the TCPDF class if you are not familiar with it.
In the next step you can create the table.
use Tcpdf\Extension\Table\Table; $pdf->AddPage(); // add a new page to the document $table = new Table($pdf); $table ->newRow() ->newCell() ->setText('Last Name') ->setFontWeight('bold') ->end() ->newCell() ->setText('First Name') ->setFontWeight('bold') ->end() ->newCell() ->setText('DOB') ->setFontWeight('bold') ->end() ->newCell() ->setText('Email') ->setFontWeight('bold') ->end() ->end() ->newRow() ->newCell('Foo')->end() ->newCell('John')->end() ->newCell('1956-04-14')->end() ->newCell('johnny@example.com')->end() ->end() ; $table->end(); // this prints the table to the PDF. Don't forget!
The above code shows how to create a very simple table. But you are able to customize table cells in different ways:
$table ->newRow() ->newCell('Last Name') // you can set the cell content like this ->setText('Override Text') // or like this ->setFontWeight('bold') // set font weight 'bold' or 'normal' ->setAlign('L') // text alignment ('L', 'C', 'R' or 'J') ->setVerticalAlign('top') // vertical alignment ('top', 'bottom' or 'middle') ->setBorder(1) // border format (like in TCPDF::MultiCell) ->setRowspan(1) // rowspan like in HTML ->setColspan(2) // colspan like in HTML ->setFontSize(10) // unit for font size is same as defined in TCPDF ->setMinHeight(10) // defining min-height of the cell like in CSS ->setPadding(2, 4) // setting cell padding (inner margin) like in CSS ->setPadding(2, 4, 5, 6) // or like this ->setWidth(125) // unit for width is same as defined in TCPDF ->end()
Background
Define a background color:
$table ->newRow() ->newCell('Last Name') ->setBackgroundColor('#ff4400') // hexadecimal RGB color code ->setBackgroundColor(array(250, 80, 10) // decimal RGB color array ->end() ->end()
It is possible to define a background image for each table cell.
$table ->newRow() ->newCell('Last Name') ->setBackgroundDpi(300) // define the resolution for the printing ->setBackgroundImage('/path/to/my/image.png') // pass the path to your image ->setBackgroundImage($binaryImageString) // or pass the binary file content of your image ->end() ->end()
naitsirch/tcpdf-extension 适用场景与选型建议
naitsirch/tcpdf-extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33.91k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「php」 「pdf」 「TCPDF」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 naitsirch/tcpdf-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 naitsirch/tcpdf-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 naitsirch/tcpdf-extension 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Provides TCPDF integration for Symfony
Alfabank REST API integration
Phalcon Model Generator
Auto-generate dummy data with realistic relationships per Model-like config classes
Php class generator
统计信息
- 总下载量: 33.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04