PHPackages                             mgrn/tfpdf - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. mgrn/tfpdf

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

mgrn/tfpdf
==========

Extended version of the tFPDF library with more features like rollback and better cell features.

1.0.2(4y ago)0421LGPL-2.1PHPPHP &gt;=8.1

Since May 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mainegreen/tFPDF)[ Packagist](https://packagist.org/packages/mgrn/tfpdf)[ RSS](/packages/mgrn-tfpdf/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

tFPDF
=====

[](#tfpdf)

Extended version of the tFPDF library with more features like rollback and enhanced cell writing call

This library is meant to provide a better interface for using the tFPDF libray, which while being a great library, suffers from a somewhat difficult to use api. By introducing a Cell object, which is a collection of all the properties you might wish to set when writing a cell, it can be significantly easier to code consistent cell calls as well as understanding why a cell looks like it does when output. Additionally color management has been improved with the Color class and a ColorsEnum object providing some base colors to use. Additionally this targets PHP 8.1 and so is strongly typed uses enums and class constants to reduce data type exceptions. Currently the library focuses on text enhancements only, and I would expect it's primary usage would be in report building, though anything tFPDF can do, this can do.

Consider the following using the old library, where $pdf is an instance of \\tfpdf:

```
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetFillColor(211,211,211);
$pdf->SetTextColor(255,0,0);
$pdf->SetDrawColor(255,0,0);
$pdf->Cell(100, 0, 'Some Text', 'TB', 0, 'center', true);

```

Vs in this library, where $pdf is an instance of Pdf:

```
$cell = new Cell();
$cell->fontFamily = 'Arial';
$cell->fontBold = true;
$cell->fontSize = 12;
$cell->fillColor = Color::fromColor(ColorsEnum::LIGHT_GRAY);
$cell->fontColor = Color::fromColor(ColorsEnum::RED);
$cell->drawColor = Color::fromColor(ColorsEnum::RED);
$cell->width = 100;
$cell->text = 'Some Text';
$cell->border(0,0,1,1);
$cell->align = AlignEnum::CENTER;
$cell->ln = false;
$cell->fill = true;

$pdf->writeCell($cell);

```

Right away it's clearer what you intend the cell to output, what the style will be. The use of class methods and enums removes the need to know what tfpdf expects it's string parameters to be. While the newer method may seem longer to set up, in a large PDF this actually becomes less. Like the following:

```
$cell = new Cell();
$cell->fontFamily = 'Arial';
$cell->fontSize = 12;
$cell->fillColor = Color::fromColor(ColorsEnum::LIGHT_GRAY);
$cell->align = AlignEnum::LEFT;
$cell->ln = false;
$cell->fill = true;

$writeCell = clone $cell;
$writeCell->width = 100;
$writeCell->text = 'Some Text';
$pdf->writeCell($writeCell);

$writeCell = clone $cell;
$writeCell->width = 50;
$writeCell->align = AlignEnum::RIGHT;
$writeCell->text = '$25.32';
$pdf->writeCell($writeCell);

```

We can set up a template cell this way, to set some basic style properties and then clone it, and only modify what changes from cell to cell. This allows clarity of code as well as making it possible to set up a template style at the beginning, and easily change it should you need to without having to change lots of Set\[property\] methods or Cell or MultiCell calls. One call performs both the function of Cell and MultiCell, and performs it in a manner more consistantly like one would expect.

Some features include:

- By setting the allowAutoWrap property on a Cell, you can make the output perform more like multicell. Additionally you can set the properties autoWrapLineHeight to set the line hieght for each wrapped line, and autoWrapMaxLines or cell height to set the maximum number of lines.
- When not doing a wrapping text call and setting autoShrink to true, the font size will be reduced to try and fit the text in a cell, down to autoShrinkMinFontSize.
- Rollback points using setRollbackPoint, rollbackTo, and clearRollbackPoints.

To use, create an instance of the \\Mgrn\\Tfpdf\\Pdf object or an instance of a class extending \\Mgrn\\Tfpdf\\Pdf. See the test for an example of how to use this library as well as what you can expect as outputs.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1464d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/60f2382ee4806b22b26f74b0c5481c955761cb2a6b7f1808b6c8707b2314a114?d=identicon)[mainegreen](/maintainers/mainegreen)

---

Top Contributors

[![mainegreen](https://avatars.githubusercontent.com/u/8040102?v=4)](https://github.com/mainegreen "mainegreen (4 commits)")

---

Tags

pdfunicodefpdftfpdf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mgrn-tfpdf/health.svg)

```
[![Health](https://phpackages.com/badges/mgrn-tfpdf/health.svg)](https://phpackages.com/packages/mgrn-tfpdf)
```

###  Alternatives

[setasign/fpdi

FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.

1.2k142.4M231](/packages/setasign-fpdi)[setasign/fpdf

FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.

77263.8M227](/packages/setasign-fpdf)[setasign/tfpdf

This class is a modified version of FPDF that adds UTF-8 support. The latest version is based on FPDF 1.85.

426.1M30](/packages/setasign-tfpdf)[tmw/fpdm

PDF form filling using FPDM Class written by FPDF author Olivier

129623.6k3](/packages/tmw-fpdm)[fpdf/fpdf

FPDF Composer Wrapper

512.7M22](/packages/fpdf-fpdf)[setasign/fpdi-protection

A FPDI compatible version of the FPDF\_Protection script.

324.3M2](/packages/setasign-fpdi-protection)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
