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

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

surda/mpdf
==========

mPDF integration into Nette Framework

v1.0.4(6y ago)0131MITPHPPHP &gt;=7.1

Since Sep 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/surda/mpdf)[ Packagist](https://packagist.org/packages/surda/mpdf)[ Docs](http://surani.cz)[ RSS](/packages/surda-mpdf/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (9)Versions (6)Used By (0)

[mPDF](https://mpdf.github.io) integration into Nette Framework
===============================================================

[](#mpdf-integration-into-nette-framework)

---

[![Build Status](https://camo.githubusercontent.com/8a0a789ba13e747a65af6adb2c3943c74739b1aafe03ed937bc9b2bab5c7c03e/68747470733a2f2f7472617669732d63692e6f72672f73757264612f6d7064662e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/surda/mpdf)[![Licence](https://camo.githubusercontent.com/978ffae19452963256eaa12d1ff3b1a9c77ad977b6385d71a739d610d8fd772c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73757264612f6d7064662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/surda/mpdf)[![Latest stable](https://camo.githubusercontent.com/d33310e8cbdbcd9eddbab697316116d0e98a61a849da78deeda2aa05e7a05bb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73757264612f6d7064662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/surda/mpdf)[![PHPStan](https://camo.githubusercontent.com/441b5874ce4df0a2defc892979c96c46889b69cb32119d04f0b48626349f8bc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d627269676874677265656e2e7376673f7374796c653d666c6174)](https://github.com/phpstan/phpstan)

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

[](#installation)

The recommended way to is via Composer:

```
composer require surda/mpdf

```

After that you have to register extension in config.neon:

```
extensions:
    mpdf: Surda\Mpdf\DI\MpdfExtension
```

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

[](#configuration)

Default

```
mpdf:
    mpdf:
        tempDir: %tempDir%/mpdf
```

Custom mPDF config

See

```
mpdf:
    mpdf:
        tempDir: %tempDir%/mpdf
        margin_left: 15
        margin_right: 15
        margin_top: 16
        margin_bottom: 16
        margin_header: 9
        margin_footer: 9
        mode: 'utf-8'
        format: 'A4'
        orientation: 'P'
        default_font_size: 0
        default_font: ''
```

Usage
-----

[](#usage)

```
use Surda\Mpdf\MpdfFactory;
use Surda\Mpdf\Response\PdfResponse;

class OrderPresenter extends Nette\Application\UI\Presenter
{
    /** @var MpdfFactory */
    private $pdfFactory;

    /**
     * @param MpdfFactory $pdfFactory
     */
    public function injectMpdfFactory(MpdfFactory $pdfFactory): void
    {
        $this->pdfFactory = $pdfFactory;
    }

    public function actionPdf(): void
    {
        $this->template->setFile('/path/to/template.latte');

        $mpdf = $this->mpdfFactory->create();
        $mpdf->WriteHTML($this->template);

        $this->sendResponse(new PdfResponse($mpdf->Output()));
    }
}
```

Create pdf with latte only
--------------------------

[](#create-pdf-with-latte-only)

```
$latte = new Latte\Engine;
$latte->setTempDirectory('/path/to/temp');

$parameters = [
    'foo' => 'bar',
];

$template = $latte->renderToString('/path/to/template.latte', $parameters);

$mpdf = $this->mpdfFactory->create();
$mpdf->WriteHTML($template);

$this->sendResponse(new PdfResponse($mpdf->Output()));
```

Responses
---------

[](#responses)

```
// Download
$this->sendResponse(new PdfResponse($mpdf->Output('file.pdf', \Mpdf\Output\Destination::DOWNLOAD)));

// Display in a browser
$this->sendResponse(new PdfResponse($mpdf->Output('file.pdf', \Mpdf\Output\Destination::INLINE)));
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

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

Total

5

Last Release

2418d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.2

v1.0.1PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

pdfnettempdf

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[contributte/pdf

Pdf response extension for Nette Framework

43967.8k2](/packages/contributte-pdf)[carlos-meneses/laravel-mpdf

Laravel Mpdf: Using Mpdf in Laravel to generate Pdfs.

4403.1M7](/packages/carlos-meneses-laravel-mpdf)[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)[kdyby/wkhtmltopdf

Wkhtmltopdf cli wrapper for Nette Framework

3966.0k](/packages/kdyby-wkhtmltopdf)

PHPackages © 2026

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