PHPackages                             stollr/tcpdf-extension - 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. stollr/tcpdf-extension

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

stollr/tcpdf-extension
======================

This library extends the TCPDF library for example with a smart API for creating tables.

v2.0.0(2y ago)11.2k↓50%MITPHPPHP &gt;=5.3.3

Since Aug 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/stollr/tcpdf-extension)[ Packagist](https://packagist.org/packages/stollr/tcpdf-extension)[ Docs](https://github.com/stollr/tcpdf-extension)[ RSS](/packages/stollr-tcpdf-extension/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (0)

TCPDF Extension
===============

[](#tcpdf-extension)

[TCPDF](http://www.tcpdf.org) 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**.

Origin Repository
-----------------

[](#origin-repository)

This repo is a fork of naitsirch/tcpdf-extension. Version `2.0.0` is compatible to `1.1.0` except for the directory structure. It now follows the PSR-4 standard.

Features
--------

[](#features)

- More comfortable creation of tables

Installation
------------

[](#installation)

Install the latest version with [Composer](http://getcomposer.org/download/):

```
composer require stollr/tcpdf-extension

```

Usage
-----

[](#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](http://www.tcpdf.org/doc/code/classTCPDF.html)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

[](#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()
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~973 days

Total

3

Last Release

880d ago

Major Versions

v1.1.0 → v2.0.02023-12-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf1cb5ce96dbe10dc182c82d49353c308404794574304aa10be000d97ea00243?d=identicon)[stollr](/maintainers/stollr)

---

Top Contributors

[![DougHayward](https://avatars.githubusercontent.com/u/4302775?v=4)](https://github.com/DougHayward "DougHayward (2 commits)")[![stollr](https://avatars.githubusercontent.com/u/1118790?v=4)](https://github.com/stollr "stollr (2 commits)")[![detook](https://avatars.githubusercontent.com/u/853431?v=4)](https://github.com/detook "detook (1 commits)")[![ianmustafa](https://avatars.githubusercontent.com/u/5209746?v=4)](https://github.com/ianmustafa "ianmustafa (1 commits)")[![leonex-cs1](https://avatars.githubusercontent.com/u/10447971?v=4)](https://github.com/leonex-cs1 "leonex-cs1 (1 commits)")

---

Tags

phppdfgeneratorTCPDF

### Embed Badge

![Health badge](/badges/stollr-tcpdf-extension/health.svg)

```
[![Health](https://phpackages.com/badges/stollr-tcpdf-extension/health.svg)](https://phpackages.com/packages/stollr-tcpdf-extension)
```

###  Alternatives

[elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[bithost-gmbh/pdfviewhelpers

This is a TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.

45242.7k2](/packages/bithost-gmbh-pdfviewhelpers)[qipsius/tcpdf-bundle

A bundle to easily integrate TCPDF into Symfony

22709.1k](/packages/qipsius-tcpdf-bundle)[tarfin-labs/easy-pdf

Makes pdf processing easy.

1718.3k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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