PHPackages                             iutbay/yii2-mpdf - 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. iutbay/yii2-mpdf

AbandonedArchivedYii2-extension[PDF &amp; Document Generation](/categories/documents)

iutbay/yii2-mpdf
================

mPDF response formatter for Yii2

0.2(10y ago)3526PHP

Since Nov 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iutbay/yii2-mpdf)[ Packagist](https://packagist.org/packages/iutbay/yii2-mpdf)[ Docs](https://github.com/iutbay/yii2-mpdf)[ RSS](/packages/iutbay-yii2-mpdf/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

yii2-mpdf
=========

[](#yii2-mpdf)

[mPDF](http://www.mpdf1.com/) response formatter for Yii2.

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

[](#installation)

The preferred way to install this response formatter is through [composer](http://getcomposer.org/download/).

Either run

```
composer require "iutbay/yii2-mpdf" "*"

```

or add

```
"iutbay/yii2-mpdf" : "*"
```

to the require section of your application's `composer.json` file.

Configuration
-------------

[](#configuration)

Add the following lines in the components section of your application configuration :

```
'response' => [
  'formatters' => [
    'mpdf' => [
      'class' => 'iutbay\yii2mpdf\MPDFResponseFormatter',

      // mPDF constructor options : http://mpdf1.com/manual/index.php?tid=184
      //'mPDFConstructorOptions' => [
        //'mode' => '',
        //'format' => 'A4',
        //'defaultFontSize' => '',
        //'defaultFont' => '',
        //'marginLeft' => 15,
        //'marginRight' => 15,
        //'marginTop' => 16,
        //'marginBottom' => 16,
        //'marginHeader' => 9,
        //'marginFooter' => 9,
        //'orientation' => 'P',
      //],

      // mPDF options : http://mpdf1.com/manual/index.php?tid=273
      //'mPDFOptions' => [],

      // css file path aliases, e.g. ['@app/web/css/pdf.css']
      //'cssFiles' => [],

      // page header : http://mpdf1.com/manual/index.php?tid=149
      //'header' => null,

      // page footer : http://mpdf1.com/manual/index.php?tid=151
      //'footer' => null,

      // ouput options : http://mpdf1.com/manual/index.php?tid=125
      //'outputName' => '',
      //'outputDest' => 'I',
    ],
  ],
],
```

Usage in controllers
--------------------

[](#usage-in-controllers)

Example 1 :

```
public function actionPdf()
{
  Yii::$app->response->format = 'mpdf';
  return $this->render('pdf');
}
```

Example 2 :

```
public function actionPdf()
{
  Yii::$app->response->format = 'mpdf';
  return [
    // mPDF construtor options : http://mpdf1.com/manual/index.php?tid=184
    //'mPDFConstructorOptions' => [],
    // mPDF options : http://mpdf1.com/manual/index.php?tid=273
    //'mPDFOptions' => [],
    'content' => $this->render('pdf'),
    //'options' => [
        // page header : http://mpdf1.com/manual/index.php?tid=149
        //'header' => 'Left|Center|Right',
        // page footer : http://mpdf1.com/manual/index.php?tid=151
        //'footer' => 'Left|Center|{PAGENO}/{nbpg}',
        // ouput options : http://mpdf1.com/manual/index.php?tid=125
        //'outputName' => 'test.pdf',
        //'outputDest' => 'D',
    //],
  ]
}
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

3809d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/273e8d8c3b73681916b6e80e2021f774dbdb4054d2ea2d0744a91baa99f6999b?d=identicon)[iutbay](/maintainers/iutbay)

---

Top Contributors

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

---

Tags

pdfyii2extensionmpdf

### Embed Badge

![Health badge](/badges/iutbay-yii2-mpdf/health.svg)

```
[![Health](https://phpackages.com/badges/iutbay-yii2-mpdf/health.svg)](https://phpackages.com/packages/iutbay-yii2-mpdf)
```

###  Alternatives

[kartik-v/yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.

1745.7M90](/packages/kartik-v-yii2-mpdf)[kartik-v/yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)

1693.3M36](/packages/kartik-v-yii2-export)[yii2assets/yii2-pdfjs

Yii2 Extension pdf.js Portable Document Format (PDF) viewer

24217.8k](/packages/yii2assets-yii2-pdfjs)[robregonm/yii2-pdf

Yii 2 PDF Response Formatter

4647.8k1](/packages/robregonm-yii2-pdf)[phpnt/yii2-export

Yii2 It saves data in xls, csv, word, html, pdf files.

158.9k](/packages/phpnt-yii2-export)

PHPackages © 2026

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