PHPackages                             anklimsk/cakephp2-tcpdf - 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. anklimsk/cakephp2-tcpdf

ActiveCakephp-plugin[PDF &amp; Document Generation](/categories/documents)

anklimsk/cakephp2-tcpdf
=======================

Generate PDF files with the CakePHP 2.x

v1.0.3(6y ago)0140MITPHPPHP &gt;=5.4

Since Aug 6Pushed 6y agoCompare

[ Source](https://github.com/anklimsk/cakephp-tcpdf)[ Packagist](https://packagist.org/packages/anklimsk/cakephp2-tcpdf)[ Docs](https://github.com/anklimsk/cakephp-tcpdf)[ RSS](/packages/anklimsk-cakephp2-tcpdf/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

CakePHP 2.x Generate PDF files plugin
=====================================

[](#cakephp-2x-generate-pdf-files-plugin)

[![Build Status](https://camo.githubusercontent.com/db2b09ffaa735101267426a9b4f6ade8e7d9a22c4b89cbf3ac4d580a03504b13/68747470733a2f2f7472617669732d63692e636f6d2f616e6b6c696d736b2f63616b657068702d74637064662e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/anklimsk/cakephp-tcpdf)[![Coverage Status](https://camo.githubusercontent.com/7107faa2db52516bf4a724f51bc9db6eb76e3c2911d6eee2c33b7dde8a12590b/68747470733a2f2f636f6465636f762e696f2f67682f616e6b6c696d736b2f63616b657068702d74637064662f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/anklimsk/cakephp-tcpdf)[![Latest Stable Version](https://camo.githubusercontent.com/57910c1dc9ef793fd744af6f6a6fc85371f8f9d0480487158721848f84598515/68747470733a2f2f706f7365722e707567782e6f72672f616e6b6c696d736b2f63616b65706870322d74637064662f762f737461626c65)](https://packagist.org/packages/anklimsk/cakephp2-tcpdf)[![License](https://camo.githubusercontent.com/4abcbc19b73930e4efcacb7aa3262b0c7df561414dd5b3c995f18f1446dcbbb6/68747470733a2f2f706f7365722e707567782e6f72672f616e6b6c696d736b2f63616b65706870322d74637064662f6c6963656e7365)](https://packagist.org/packages/anklimsk/cakephp2-tcpdf)

Generate PDF files with the CakePHP

This plugin provides next features:
-----------------------------------

[](#this-plugin-provides-next-features)

- Generate PDF files

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

[](#installation)

1. Install the Plugin using composer: `composer require anklimsk/cakephp2-tcpdf`
2. Add the next line to the end of the file `app/Config/bootstrap.php`:

    ```
    CakePlugin::load('CakeTCPDF', ['bootstrap' => true, 'routes' => true]);
    ```

Using this plugin
-----------------

[](#using-this-plugin)

1. In your `Model`:

    - Create the following methods:

        ```
        public function getExportConfig() {
            $header = [__('Field label 1'), __('Field label 2'), __('Field label 3'), __('Field label 4')];
            $width = [35, 20, 10, 15];
            $align = ['L', 'L', 'C', 'R'];
            $fileName = __('Export file');

            return compact('header', 'width', 'align', 'fileName');
        }

        public function getExportData($conditions = []) {
            ...
            $result = [
                'Group header (List name)' => [
                    'Sub header' => [
                        [
                            'Field value 1',
                            'Field value 2',
                            'Field value 3',
                            'Field value 4',
                        ]
                    ]
                ]
            ];

            return $result;
        }
        ```
2. In your `Controller`:

    - Add the `RequestHandler` component to `AppController`, and map `pdf` to the CakeTCPDF plugin, e.g.:

        ```
        public $components = [
            ...,
            'RequestHandler' => [
                'viewClassMap' => [
                    'pdf' => 'CakeTCPDF.Pdf'
                ]
            ]
        );
        ```
    - Add to your controller action:

        ```
        public export($id = null) {
            if (!$this->RequestHandler->prefers('pdf')) {
                throw new BadRequestException(__('Invalid export type');
            }

            $conditions = [];
            if (!empty($id)) {
                $conditions['Model.id'] = $id;
            }
            $exportConfig = $this->Model->getExportConfig();
            $exportData = $this->Model->getExportData();

            $this->set(compact('exportConfig', 'exportData'));
        }
        ```
3. In your `View`:

    - Create a link to the a action with the extension `.pdf`, e.g.:

        ```
        $this->Html->link('PDF file', ['ext' => 'pdf']);
        ```
    - Place the View templates in the subdirectory `Pdf`, e.g.: `app/View/Invoices/Pdf/index.ctp`
    - Use the `CakeTCPDF.exportPdfTable` element in your View file, e.g.:

        ```
        if (!empty($exportConfig)) {
            extract($exportConfig);
        }

        if (!isset($orientation)) {
            $orientation = PDF_PAGE_ORIENTATION;
        }

        if (isset($fileName)) {
            $this->setFileName($fileName);
        }

        $this->tcpdf->setPageOrientation($orientation, TRUE, PDF_MARGIN_BOTTOM);
        $this->tcpdf->options['footerText'] = $this->tcpdf->getAliasNumPage();

        // set font
        $this->tcpdf->SetFont(PDF_FONT_NAME_DATA, 'B', PDF_FONT_SIZE_DATA);
        // set default font subsetting mode
        $this->tcpdf->setFontSubsetting(true);

        //set margins
        $this->tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $this->tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $this->tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);

        $this->tcpdf->AddPage();
        $this->tcpdf->setPrintFooter(true);
        echo $this->element('CakeTCPDF.exportPdfTable', compact('exportConfig', 'exportData'));
        ```
    - Use the `CakeTCPDF.exportPdfTableContent` element in your View file, e.g.:

        ```
        echo $this->element('CakeTCPDF.exportPdfTableContent', compact('exportConfig'));
        ```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Recently: every ~137 days

Total

7

Last Release

2233d ago

Major Versions

v0.1.4 → v1.0.02018-10-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/140887a79183c767c877d9ddb80aeaf88e0abd091f8dc1cd6e599ab7e30e1d82?d=identicon)[anklimsk](/maintainers/anklimsk)

---

Top Contributors

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

---

Tags

cakephp-plugincakephp2tcpdf

### Embed Badge

![Health badge](/badges/anklimsk-cakephp2-tcpdf/health.svg)

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

###  Alternatives

[renatio/dynamicpdf-plugin

October HTML to PDF converter using dompdf library.

3113.4k3](/packages/renatio-dynamicpdf-plugin)[k1low/yacsv

Yet another CSV utility plugin for CakePHP

124.0k](/packages/k1low-yacsv)[luketowers/oc-snappypdf-plugin

SnappyPDF integration for OctoberCMS

121.1k](/packages/luketowers-oc-snappypdf-plugin)

PHPackages © 2026

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