PHPackages                             perochak/yii2-pdf - 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. perochak/yii2-pdf

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

perochak/yii2-pdf
=================

Yii 2 PDF Response Formatter

1.1.3(4y ago)053BSD-3-ClausePHP

Since Jul 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/perochak/yii2-pdf)[ Packagist](https://packagist.org/packages/perochak/yii2-pdf)[ RSS](/packages/perochak-yii2-pdf/feed)WikiDiscussions main Synced 1mo ago

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

Yii2-PDF
========

[](#yii2-pdf)

PDF formatter for Yii2 using mPDF library.

This extension "format" HTML responses to PDF files (by default Yii2 includes HTML, JSON and XML formatters). Great for reports in PDF format using HTML views/layouts.

\##Installation

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

Either run

```
$ php composer.phar require perochak/yii2-pdf "*"

```

or add

```
"robregonm/yii2-pdf": "*"

```

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

Usage
-----

[](#usage)

Once the extension is installed, modify your application configuration to include:

```
return [
	'components' => [
		...
		'response' => [
			'formatters' => [
				'pdf' => [
					'class' => 'robregonm\pdf\PdfResponseFormatter',
					'mode' => '', // Optional
					'format' => 'A4',  // Optional but recommended. http://mpdf1.com/manual/index.php?tid=184
					'defaultFontSize' => 0, // Optional
					'defaultFont' => '', // Optional
					'marginLeft' => 15, // Optional
					'marginRight' => 15, // Optional
					'marginTop' => 16, // Optional
					'marginBottom' => 16, // Optional
					'marginHeader' => 9, // Optional
					'marginFooter' => 9, // Optional
					'orientation' => 'Landscape', // optional. This value will be ignored if format is a string value.
					'options' => [
						// mPDF Variables
						// 'fontdata' => [
							// ... some fonts. http://mpdf1.com/manual/index.php?tid=454
						// ]
					]
				],
			]
		],
		...
	],
];
```

In the controller:

```
class MyController extends Controller {
	public function actionPdf(){
		Yii::$app->response->format = 'pdf';

		// Rotate the page
		Yii::$container->set(Yii::$app->response->formatters['pdf']['class'], [
			'format' => [216, 356], // Legal page size in mm
			'orientation' => 'Landscape', // This value will be used when 'format' is an array only. Skipped when 'format' is empty or is a string
			'beforeRender' => function($mpdf, $data) {},
			]);

		$this->layout = '//print';
		return $this->render('myview', []);
	}
}
```

License
-------

[](#license)

Yii2-Pdf is released under the BSD-3 License. See the bundled `LICENSE.md` for details.

Useful URLs
===========

[](#useful-urls)

- [mPDF Manual](http://mpdf1.com/manual/index.php)

Enjoy!

[![Flattr this git repo](https://camo.githubusercontent.com/7e3f46a36526479d701ef7f90a0f8c3ac2fbab3087446e2a9fceed75cd1ab802/687474703a2f2f6170692e666c617474722e636f6d2f627574746f6e2f666c617474722d62616467652d6c617267652e706e67)](https://flattr.com/submit/auto?user_id=robregonm&url=https://github.com/robregonm/yii2-pdf&title=Yii2-PDF&language=&tags=github&category=software)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

1764d ago

PHP version history (2 changes)1.1.1PHP ^7.4.0

1.1.2PHP ^7.4

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

responseformatterpdfyii2yiireportsdocuments

### Embed Badge

![Health badge](/badges/perochak-yii2-pdf/health.svg)

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

###  Alternatives

[robregonm/yii2-pdf

Yii 2 PDF Response Formatter

4647.5k1](/packages/robregonm-yii2-pdf)[kartik-v/yii2-mpdf

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

1605.5M84](/packages/kartik-v-yii2-mpdf)[borales/yii-pdf

Yii-wrapper for PHP-PDF libraries (mPDF, HTML2PDF)

60109.1k](/packages/borales-yii-pdf)[yii2assets/yii2-pdfjs

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

23209.3k](/packages/yii2assets-yii2-pdfjs)[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)
