PHPackages                             vzool/laravel-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. vzool/laravel-pdf

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

vzool/laravel-pdf
=================

Generate PDFs in Laravel with this mPDF wrapper.

v1.63(5y ago)12.2k↓100%MITPHPPHP ^8.0

Since Dec 27Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (7)Used By (0)

Laravel PDF: mPDF wrapper for Laravel 5
=======================================

[](#laravel-pdf-mpdf-wrapper-for-laravel-5)

> Easily generate PDF documents from HTML right inside of Laravel using this mPDF wrapper.

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

[](#installation)

Require this package in your `composer.json` or install it by running:

```
composer require vzool/laravel-pdf

```

To start using Laravel, add the Service Provider and the Facade to your `config/app.php`:

```
'providers' => [
	// ...
	vzool\LaravelPdf\PdfServiceProvider::class
]

```

```
'aliases' => [
	// ...
	'PDF' => vzool\LaravelPdf\Facades\Pdf::class
]

```

Basic Usage
-----------

[](#basic-usage)

To use Laravel PDF add something like this to one of your controllers. You can pass data to a view in `/resources/views`.

```
use PDF;

function generate_pdf() {
	$data = [
		'foo' => 'bar'
	];
	$pdf = PDF::loadView('pdf.document', $data);
	return $pdf->stream('document.pdf');
}

```

Config
------

[](#config)

You can use a custom file to overwrite the default configuration. Just create `config/pdf.php` and add this:

```
return [
	'mode'               => '',
	'format'             => 'A4',
	'defaultFontSize'    => '12',
	'defaultFont'        => 'sans-serif',
	'marginLeft'         => 10,
	'marginRight'        => 10,
	'marginTop'          => 10,
	'marginBottom'       => 10,
	'marginHeader'       => 0,
	'marginFooter'       => 0,
	'orientation'        => 'P',
	'title'              => 'Laravel PDF',
	'author'             => '',
	'watermark'          => '',
	'showWatermark'      => false,
	'watermarkFont'      => 'sans-serif',
	'SetDisplayMode'     => 'fullpage',
	'watermarkTextAlpha' => 0.1
];

```

Headers and Footers
-------------------

[](#headers-and-footers)

If you want to have headers and footers that appear on every page, add them to your `` tag like this:

```

	Your Header Content

	Your Footer Content

```

Now you just need to define them with the name attribute in your CSS:

```
@page {
	header: page-header;
	footer: page-footer;
}

```

Inside of headers and footers `{PAGENO}` can be used to display the page number.

Included Fonts
--------------

[](#included-fonts)

By default you can use all the fonts [shipped with mPDF](https://mpdf.github.io/fonts-languages/available-fonts-v6.html).

Custom Fonts
------------

[](#custom-fonts)

You can use your own fonts in the generated PDFs. The TTF files have to be located in one folder, e.g. `/resources/fonts/`. Add this to your configuration file (`/config/pdf.php`):

```
return [
	'custom_font_path' => base_path('/resources/fonts/'), // don't forget the trailing slash!
	'custom_font_data' => [
		'examplefont' => [
			'R'  => 'ExampleFont-Regular.ttf',    // regular font
			'B'  => 'ExampleFont-Bold.ttf',       // optional: bold font
			'I'  => 'ExampleFont-Italic.ttf',     // optional: italic font
			'BI' => 'ExampleFont-Bold-Italic.ttf' // optional: bold-italic font
		]
		// ...add as many as you want.
	]
];

```

Now you can use the font in CSS:

```
body {
	font-family: 'examplefont', sans-serif;
}

```

Set Protection
--------------

[](#set-protection)

To set protection, you just call the `SetProtection()` method and pass an array with permissions, an user password and an owner password.

The passwords are optional.

There are a fews permissions: `'copy'`, `'print'`, `'modify'`, `'annot-forms'`, `'fill-forms'`, `'extract'`, `'assemble'`, `'print-highres'`.

```
use PDF;

function generate_pdf() {
	$data = [
		'foo' => 'bar'
	];
	$pdf = PDF::loadView('pdf.document', $data);
	$pdf->SetProtection(['copy', 'print'], '', 'pass');
	return $pdf->stream('document.pdf');
}

```

Find more information to `SetProtection()` here:

Extra
-----

[](#extra)

Add a new instance called `instance` which will return your **mPDF** instance.

License
-------

[](#license)

Laravel PDF is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

Established project with proven stability

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

Recently: every ~391 days

Total

6

Last Release

1857d ago

PHP version history (2 changes)v1.4.1PHP &gt;=5.4.0

v1.6PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laravelpdfmpdf

### Embed Badge

![Health badge](/badges/vzool-laravel-pdf/health.svg)

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

###  Alternatives

[carlos-meneses/laravel-mpdf

Laravel Mpdf: Using Mpdf in Laravel to generate Pdfs.

4403.1M7](/packages/carlos-meneses-laravel-mpdf)

PHPackages © 2026

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