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

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

galmet/mpdf-port-bundle
=======================

A wrapper for mPDF class which allows to use mPDF in Symfony2 projects

1.2.2b(12y ago)0593MITPHP

Since May 11Pushed 12y ago1 watchersCompare

[ Source](https://github.com/galmet/MpdfPortBundle)[ Packagist](https://packagist.org/packages/galmet/mpdf-port-bundle)[ Docs](http://github.com/tasmanianfox/MpdfPortBundle)[ RSS](/packages/galmet-mpdf-port-bundle/feed)WikiDiscussions master Synced 1mo ago

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

Installation
============

[](#installation)

### Using Composer (Symfony 2.1+)

[](#using-composer-symfony-21)

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

```
"require": {
		...

        "tfox/mpdf-port-bundle": "1.2.*"
}

```

- Run a command

```
php composer.phar update

```

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

```
$bundles = array(
  ...
  new TFox\MpdfPortBundle\TFoxMpdfPortBundle(),
)

```

### Using deps-file (Symfony 2.0.x)

[](#using-deps-file-symfony-20x)

- Add a new entry to your `deps` file:

```
[TFoxMpdfPortBundle]
    git=https://github.com/tasmanianfox/MpdfPortBundle.git
    target=/bundles/TFox/MpdfPortBundle

```

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

```
new TFox\MpdfPortBundle\TFoxMpdfPortBundle(),

```

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

```
'TFox' => __DIR__.'/../vendor/bundles',

```

- Run a command

```
php bin/vendors install

```

A Quick Start guide
===================

[](#a-quick-start-guide)

### How to create a Response object

[](#how-to-create-a-response-object)

This small example creates a PDF document with format A4 and portrait orientation:

```
$mpdfService = $this->get('tfox.mpdfport');
$html = "Hello World!";
$response = $mpdfService->generatePdfResponse($html);

```

### Generate a variable with PDF content

[](#generate-a-variable-with-pdf-content)

Sometimes it is necessary to get a variabe which content is PDF document. Obviously, you might generate a response from the previous example and then call a method:

```
$response->getContent()

```

But there is a shorter way to get a raw content:

```
$mpdfService = $this->get('tfox.mpdfport');
$html = "Hello World!";
$content = $mpdfService->generatePdf($html);

```

### How to get an instance of \\mPDF class

[](#how-to-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('tfox.mpdfport');
$mPDF = $mpdfService->getMpdf();

```

Warning
=======

[](#warning)

- By default the bundle adds the two attributes 'utf-8' and 'A4' to the mPDF class constructor. To turn off these options, use the `setAddDefaultConstructorArgs` method:

```
$mpdfService->setAddDefaultConstructorArgs(false);

```

- As the bundle inserts the first two arguments to the mPDF constructor by default, additional constructor arguments should start from the 3rd argument (default\_font\_size).
- If the `setAddDefaultConstructorArgs(false)` method is called, additional arguments for constructor should start from the first one (mode).

Additional arguments
====================

[](#additional-arguments)

As the bundle uses methods of mPDF class, some additional parameters can be added to these methods. There are 3 mPDF methods used in the bundle:

- Constructor. Documentation:
- WriteHTML. Documentation:
- Output. Documentation:

To pass additional arguments, an array with arguments should be created:

```
$arguments = array(
	'constructorArgs' => array(), //Constructor arguments. Numeric array. Don't forget about points 2 and 3 in Warning section!
	'writeHtmlMode' => null, //$mode argument for WriteHTML method
	'writeHtmlInitialise' => null, //$mode argument for WriteHTML method
	'writeHtmlClose' => null, //$close argument for WriteHTML method
	'outputFilename' => null, //$filename argument for Output method
	'outputDest' => null //$dest argument for Output method
);

```

It is NOT necessary to have all the keys in array. This array might be passed to the `generatePdf` and `generatePdfResponse` methods as the second argument:

```
$mpdfService->generatePdf($html, $arguments);
$mpdfService->generatePdfResponse($html, $arguments);

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~64 days

Total

5

Last Release

4490d ago

### Community

Maintainers

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

---

Top Contributors

[![BillyTom](https://avatars.githubusercontent.com/u/953688?v=4)](https://github.com/BillyTom "BillyTom (5 commits)")[![markitosgv](https://avatars.githubusercontent.com/u/1706470?v=4)](https://github.com/markitosgv "markitosgv (3 commits)")[![sergbelyakov](https://avatars.githubusercontent.com/u/36037228?v=4)](https://github.com/sergbelyakov "sergbelyakov (2 commits)")

---

Tags

pdfmpdf

### Embed Badge

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

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

###  Alternatives

[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)[contributte/pdf

Pdf response extension for Nette Framework

43967.8k2](/packages/contributte-pdf)

PHPackages © 2026

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