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

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

kvr001/yii2-mpdf
================

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

V1.100.1(4y ago)0122BSD-3-ClauseCSS

Since Nov 10Pushed 4y agoCompare

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

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

 [ ![Krajee Logo](https://camo.githubusercontent.com/4addfbb3869c3fc7d79befea4f06d9cf3655a686fb503df0da1d725859cfdef9/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f6b72616a65652d6c6f676f2d622e706e67) ](http://demos.krajee.com "Krajee Demos")
 yii2-mpdf ---

 [ ![Donate](https://camo.githubusercontent.com/4af77d425ca202e55ab3d711b438e238ded194735bc345a019ac060e03e26227/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f646f6e6174652e706e67) ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU "Donate via Paypal")
=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#------------------------yii2-mpdf--------------------)

[![Stable Version](https://camo.githubusercontent.com/3bf1ddde4a5ca6e56c092f3e1c95299c975d8ce833a0b051a0022b2b19d7d797/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6d7064662f762f737461626c65)](https://packagist.org/packages/kartik-v/yii2-mpdf)[![Unstable Version](https://camo.githubusercontent.com/c284abcd35a0055617d315f9af8e141ec7e1a57db04026df7d0ef7e7a0349bd9/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6d7064662f762f756e737461626c65)](https://packagist.org/packages/kartik-v/yii2-mpdf)[![License](https://camo.githubusercontent.com/cf591378a257f054766c97d9c3d03b790f3ac730fbc37b533441fa9ee2c7a123/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6d7064662f6c6963656e7365)](https://packagist.org/packages/kartik-v/yii2-mpdf)[![Total Downloads](https://camo.githubusercontent.com/0a04038e96440479c50a34a0f7bd13f2f5308d747cacea0e68fe2f6bb78827ec/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6d7064662f646f776e6c6f616473)](https://packagist.org/packages/kartik-v/yii2-mpdf)[![Monthly Downloads](https://camo.githubusercontent.com/b53b766ff6c30ed24493934789c07a9ec340320545ff3951ec4cf5bd17382e51/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6d7064662f642f6d6f6e74686c79)](https://packagist.org/packages/kartik-v/yii2-mpdf)[![Daily Downloads](https://camo.githubusercontent.com/73a1bcc5d49c4b755d1bb994d134ad5704b0d20082f72faf88c16c8958a00afc/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d6d7064662f642f6461696c79)](https://packagist.org/packages/kartik-v/yii2-mpdf)

The **yii2-mpdf** extension is a Yii2 wrapper component for the [mPDF library](http://www.mpdf1.com/) with enhancements. The mPDF library offers ability to generate PDF files from UTF-8 encoded HTML. This library is based on [FPDF](http://www.fpdf.org/) and [HTML2FPDF](http://html2fpdf.sourceforge.net/), with a number of enhancements. The key features in the library are to be able to generate PDF files 'on-the-fly' from HTML content, handling different languages. Refer the [documentation manual](https://mpdf.github.io) or the [upstream mpdf site](http://mpdf1.com) for further details and understanding of the library. The yii2-mpdf extension offers an easy way to integrate and use the mPDF library within your Yii application with subtle enhancements. The key features offerred with this release are:

- Setup `pdf` component globally in your yii application configuration.
- Setup mPDF properties or call mPDF methods easily using simple array configuration.
- Enhances extension to setup your own custom CSS file for rendering the formatted HTML content.
- Extension has a built-in version of bootstrap.css (v3.3.0 modified for mPDF) to be applied by default. This will allow you to generate PDF content from bootstrap markup HTML easily.
- Offers easy way to prepend inline CSS in addition to your own CSS file.
- Offers easy to use object oriented methods to render complex PDF.
- Easy use of the extension like any Yii widget by using the render method with minimal configuration.
- The extension uses the latest development version (v6.0beta) of the mPDF library. It uses the composer repository `kartik-v/mpdf` on packagist as a source for this latest version. mPDF 6.0 can utilise OpenType layout tables to display complex scripts. This release (v6.0) contains fonts (open source) to cover almost every imaginable script / language. Includes support for Arabic or Indic scripts (as well as Khmer, Lao, Myanmar etc.). It also is expected to improve the display of Thai, Vietnamese and Hebrew. It also includes additional fonts for Chinese, Japanese, and Korean.
- Inbuilt integration with [yii2-grid](http://demos.krajee.com/grid) extension that allows you to export grid as PDF and even generate advanced PDF reports.

### Demo

[](#demo)

Read the detailed [documentation and usage](http://demos.krajee.com/mpdf) of the extension.

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

[](#installation)

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

> Note: Check the [composer.json](https://github.com/kartik-v/yii2-mpdf/blob/master/composer.json) for this extension's requirements and dependencies. Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.

Either run

```
$ php composer.phar require kartik-v/yii2-mpdf "dev-master"

```

or add

```
"kartik-v/yii2-mpdf": "dev-master"

```

to the `require` section of your `composer.json` file.

Usage
-----

[](#usage)

### Widget Like Usage

[](#widget-like-usage)

The component can be used straightforward in a manner similar to any widget to render your HTML content as PDF. For example, you can call the component simply like below in your controller action:

```
use kartik\mpdf\Pdf;

public function actionReport() {
    // get your HTML raw content without any layouts or scripts
    $content = $this->renderPartial('_reportView');

    // setup kartik\mpdf\Pdf component
    $pdf = new Pdf([
        // set to use core fonts only
        'mode' => Pdf::MODE_CORE,
        // A4 paper format
        'format' => Pdf::FORMAT_A4,
        // portrait orientation
        'orientation' => Pdf::ORIENT_PORTRAIT,
        // stream to browser inline
        'destination' => Pdf::DEST_BROWSER,
        // your html content input
        'content' => $content,
        // format content from your own css file if needed or use the
        // enhanced bootstrap css built by Krajee for mPDF formatting
        'cssFile' => '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css',
        // any css to be embedded if required
        'cssInline' => '.kv-heading-1{font-size:18px}',
         // set mPDF properties on the fly
        'options' => ['title' => 'Krajee Report Title'],
         // call mPDF methods on the fly
        'methods' => [
            'SetHeader'=>['Krajee Report Header'],
            'SetFooter'=>['{PAGENO}'],
        ]
    ]);

    // return the pdf output as per the destination setting
    return $pdf->render();
}
```

### Global Component

[](#global-component)

You can also setup the widget as a global component for use across your application with defaults preset. For example, setup the following in the components section of your Yii application configuration file:

```
use kartik\mpdf\Pdf;
// ...
'components' => [
    // setup Krajee Pdf component
    'pdf' => [
        'class' => Pdf::classname(),
        'format' => Pdf::FORMAT_A4,
        'orientation' => Pdf::ORIENT_PORTRAIT,
        'destination' => Pdf::DEST_BROWSER,
        // refer settings section for all configuration options
    ]
]
```

Once you have setup the component, you can refer it across your application easily:

```
$pdf = Yii::$app->pdf;
$pdf->content = $htmlContent;
return $pdf->render();
```

For other usage and details, read the detailed [documentation](http://demos.krajee.com/mpdf).

Contributors
------------

[](#contributors)

### Code Contributors

[](#code-contributors)

This project exists thanks to all the people who contribute. \[[Contribute](CONTRIBUTING.md)\]. [![](https://camo.githubusercontent.com/4fa0e0a620f3d85e7566a0b1c006593dd7847c70124d6888a488d73b4eb86f69/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/kartik-v/yii2-mpdf/graphs/contributors)

### Financial Contributors

[](#financial-contributors)

Become a financial contributor and help us sustain our community. \[[Contribute](https://opencollective.com/yii2-mpdf/contribute)\]

#### Individuals

[](#individuals)

[![](https://camo.githubusercontent.com/f2328555cb1bb930f6d1835a6ebae64ec078fe56fb72a729c79b4eb43bc9184d/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f696e646976696475616c732e7376673f77696474683d383930)](https://opencollective.com/yii2-mpdf)

#### Organizations

[](#organizations)

Support this project with your organization. Your logo will show up here with a link to your website. \[[Contribute](https://opencollective.com/yii2-mpdf/contribute)\]

[![](https://camo.githubusercontent.com/c5c118a1766fa13e540651d7260061df550fe7c02db2bcf41ba36f59d6c8e2bb/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f302f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/0/website)[![](https://camo.githubusercontent.com/64469edc41cfe2af43e066ad69a7d61dbdeb77ef1d839e290b8785c7c4717f57/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f312f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/1/website)[![](https://camo.githubusercontent.com/a3d87b57711df6791def6dc88e042c4b1ed7620e42ffdf67c54c28d4d1141500/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f322f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/2/website)[![](https://camo.githubusercontent.com/4c0b2c7694646830498cd6e74de0c6b1105a42e96a47c501aecd0da9bc19c352/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f332f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/3/website)[![](https://camo.githubusercontent.com/8a3ef3412a33b8d75f79fb880654801fa630c50cbef3c20b94c10719029d8b0e/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f342f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/4/website)[![](https://camo.githubusercontent.com/5c1b29edfe7f28f0be6b5cd6a27573bbd974eb818792046045929597be4b9850/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f352f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/5/website)[![](https://camo.githubusercontent.com/e0e20e6d62b3bd454483df79829ce7bc9deee2f03b36214555898c040c0d9512/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f362f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/6/website)[![](https://camo.githubusercontent.com/9836ad1c658530dabe059f74ed0a0d91bc19209578a7387861730767674865af/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f372f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/7/website)[![](https://camo.githubusercontent.com/1b2b4be1a8782ea5e8ac9a2841a3c275926504b68f1ea49a87013f1552dbbf0f/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f382f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/8/website)[![](https://camo.githubusercontent.com/8b5c1f88dd179eb2389545ab97757cb934abfcd6393b6be5eee5a84279532b16/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f796969322d6d7064662f6f7267616e697a6174696f6e2f392f6176617461722e737667)](https://opencollective.com/yii2-mpdf/organization/9/website)

License
-------

[](#license)

**yii2-mpdf** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.

###  Health Score

31

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 70.1% 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 ~213 days

Recently: every ~90 days

Total

12

Last Release

1810d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ac7a6b081461d99924c311e7432c3c8e92a398fb679f31e102b24478b297330?d=identicon)[kvr001](/maintainers/kvr001)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (47 commits)")[![kvr001](https://avatars.githubusercontent.com/u/7407306?v=4)](https://github.com/kvr001 "kvr001 (5 commits)")[![razvanphp](https://avatars.githubusercontent.com/u/4599319?v=4)](https://github.com/razvanphp "razvanphp (3 commits)")[![niklaswolf](https://avatars.githubusercontent.com/u/16021919?v=4)](https://github.com/niklaswolf "niklaswolf (2 commits)")[![AgnisLV](https://avatars.githubusercontent.com/u/15079301?v=4)](https://github.com/AgnisLV "AgnisLV (2 commits)")[![i-lie](https://avatars.githubusercontent.com/u/6406255?v=4)](https://github.com/i-lie "i-lie (1 commits)")[![finwe](https://avatars.githubusercontent.com/u/195675?v=4)](https://github.com/finwe "finwe (1 commits)")[![kevinspacey](https://avatars.githubusercontent.com/u/795918?v=4)](https://github.com/kevinspacey "kevinspacey (1 commits)")[![glpzzz](https://avatars.githubusercontent.com/u/13596248?v=4)](https://github.com/glpzzz "glpzzz (1 commits)")[![matperez](https://avatars.githubusercontent.com/u/1917115?v=4)](https://github.com/matperez "matperez (1 commits)")[![monkeywithacupcake](https://avatars.githubusercontent.com/u/7316730?v=4)](https://github.com/monkeywithacupcake "monkeywithacupcake (1 commits)")[![DaveFerger](https://avatars.githubusercontent.com/u/1530856?v=4)](https://github.com/DaveFerger "DaveFerger (1 commits)")[![hamrak](https://avatars.githubusercontent.com/u/5807028?v=4)](https://github.com/hamrak "hamrak (1 commits)")

---

Tags

pdfutf8htmlyii2extensioncomponentmpdf

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/kvr001-yii2-mpdf/health.svg)](https://phpackages.com/packages/kvr001-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.4M79](/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.)

1703.1M34](/packages/kartik-v-yii2-export)[yii2assets/yii2-pdfjs

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

24207.4k](/packages/yii2assets-yii2-pdfjs)[phpnt/yii2-export

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

158.9k](/packages/phpnt-yii2-export)[daandesmedt/phpheadlesschrome

A PHP wrapper for using Google Chrome Headless mode. Convert URL or HTML to a PDF / screenshot. Easy to use and OOP interfaced.

92225.4k](/packages/daandesmedt-phpheadlesschrome)

PHPackages © 2026

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