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

ActiveSymfony-bundle[PDF &amp; Document Generation](/categories/documents)

vel/mpdf-bundle
===============

A wrapper for mPDF which allows to use mPDF in Symfony 2.3|~3.0 projects

21.3kPHP

Since Apr 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/astterx/MpdfBundle)[ Packagist](https://packagist.org/packages/vel/mpdf-bundle)[ RSS](/packages/vel-mpdf-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

MpdfBundle is a wrapper service for mPDF class, created for Symfony projects.

### Installation (Symfony 2.x, Symfony 3.0.x)

[](#installation-symfony-2x-symfony-30x)

- Add a new line to your `composer.json` file:

```
"require": {
    ...
    "vel/mpdf-bundle": "dev-master"
}

```

- Run composer update command

```
php composer.phar update

```

- Add a new line to `app/AppKernel.php`:

```
$bundles = array(
...
new Vel\MpdfBundle\VelMpdfBundle(),
)

```

### Documentation

[](#documentation)

#### Create Response object

[](#create-response-object)

This example creates a PDF document from HTML code with default options (font, font size, margins, orientation):

```
$mpdfService = $this->get('vel.mpdf');
$html = 'Hello world';
$respose = $mpdfService->generatePDFResponseFromHTML($html);

```

#### Generate PDF content and store into a string variable

[](#generate-pdf-content-and-store-into-a-string-variable)

```
$mpdfService = $this->get('vel.mpdf');
$html = 'Hello world';
$content = $mpdfService->generatePDF($html);

```

#### Use different options to generate a PDF document with text header and HTML footer

[](#use-different-options-to-generate-a-pdf-document-with-text-header-and-html-footer)

```
$mpdfService = $this->get('vel.mpdf');
$mpdfService->createMpdfInstance(
        $format = 'A4',
        $fontSize = 0, //default
        $fontFamily = '', //default
        $marginLeft = 15,
        $marginRight = 15,
        $marginTop = 16,
        $marginBottom = 16,
        $marginHeader = 9,
        $marginFooter = 9,
        $orientation = 'P' // P for portrait, L for landscape
      );
$mpdfService->getMpdf()->setHeader('Text header');
$mpdfService->getMpdf()->setHTMLFooter('Footer text');
$html = 'Hello world';
$mpdfService->generatePDFResponseFromHTML($html)

```

By default the bundle add 'utf-8' to mPDF constructor class.

#### Get an instance of \\mPDF class

[](#get-an-instance-of-mpdf-class)

If you would like to work with mPDF class itself, you can use a getMpdf method:

```
$mpdfService = $this->get('vel.mpdf');
$mPDF = $mpdfService->getMpdf();

```

Read mPDF documentation for more options:

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/50dc63d26cf39c0675841e6822d079ab1fa539d71a3ca455570d1e0a42d8b12f?d=identicon)[astterx](/maintainers/astterx)

---

Top Contributors

[![astterx](https://avatars.githubusercontent.com/u/7818358?v=4)](https://github.com/astterx "astterx (3 commits)")

### Embed Badge

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

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

###  Alternatives

[tarfin-labs/easy-pdf

Makes pdf processing easy.

1719.9k](/packages/tarfin-labs-easy-pdf)

PHPackages © 2026

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