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

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

peripteraptos/laravel-pdf
=========================

Generate PDFs in Laravel with this mPDF wrapper.

v5.0.4(4y ago)0208MITPHPPHP ^8

Since Apr 23Pushed 4y agoCompare

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

READMEChangelogDependencies (3)Versions (27)Used By (0)

Laravel PDF: mPDF wrapper for Laravel 8
=======================================

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

> 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 niklasravnsborg/laravel-pdf

```

Now, you should publish package's config file to your config directory by using following command:

```
php artisan vendor:publish

```

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');
}
```

Other methods
-------------

[](#other-methods)

It is also possible to use the following methods on the `pdf` object:

`output()`: Outputs the PDF as a string.
`save($filename)`: Save the PDF to a file
`download($filename)`: Make the PDF downloadable by the user.
`stream($filename)`: Return a response with the PDF to show in the browser.

Config
------

[](#config)

If you have published config file, you can change the default settings in `config/pdf.php` file:

```
return [
	'format'           => 'A4', // See https://mpdf.github.io/paging/page-size-orientation.html
	'author'           => 'John Doe',
	'subject'          => 'This Document will explain the whole universe.',
	'keywords'         => 'PDF, Laravel, Package, Peace', // Separate values with comma
	'creator'          => 'Laravel Pdf',
	'display_mode'     => 'fullpage'
];
```

To override this configuration on a per-file basis use the fourth parameter of the initializing call like this:

```
PDF::loadView('pdf', $data, [], [
  'format' => 'A5-L'
])->save($pdfFilePath);
```

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.

Find more information to `SetProtection()` here:

Testing
-------

[](#testing)

To use the testing suite, you need some extensions and binaries for your local PHP. On macOS, you can install them like this:

```
brew install imagemagick ghostscript
pecl install imagick

```

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 55.7% 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 ~85 days

Recently: every ~0 days

Total

26

Last Release

1532d ago

Major Versions

v1.5.0 → v2.0.02017-12-03

v2.0.3 → v3.0.12018-11-08

v3.1.0 → v4.0.02020-02-01

v4.1.4 → v5.0.02022-02-28

PHP version history (4 changes)v1.0.0PHP &gt;=5.4.0

v2.0.0PHP &gt;=5.6

v3.0.1PHP &gt;=7.0

v5.0.0PHP ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/3edb2b99a9e09432c08d2d022c7d8329b2d60580da82db3ff19c7cc5714a9d6f?d=identicon)[peripterptos](/maintainers/peripterptos)

---

Top Contributors

[![niklasravnsborg](https://avatars.githubusercontent.com/u/6717303?v=4)](https://github.com/niklasravnsborg "niklasravnsborg (34 commits)")[![erfansahaf](https://avatars.githubusercontent.com/u/12012168?v=4)](https://github.com/erfansahaf "erfansahaf (6 commits)")[![peripteraptos](https://avatars.githubusercontent.com/u/23555520?v=4)](https://github.com/peripteraptos "peripteraptos (6 commits)")[![daveismynamecom](https://avatars.githubusercontent.com/u/60222583?v=4)](https://github.com/daveismynamecom "daveismynamecom (5 commits)")[![stefanullrich](https://avatars.githubusercontent.com/u/3226657?v=4)](https://github.com/stefanullrich "stefanullrich (2 commits)")[![tezkerek](https://avatars.githubusercontent.com/u/12715035?v=4)](https://github.com/tezkerek "tezkerek (2 commits)")[![urielo](https://avatars.githubusercontent.com/u/10448109?v=4)](https://github.com/urielo "urielo (1 commits)")[![HarryTheWulf](https://avatars.githubusercontent.com/u/4353340?v=4)](https://github.com/HarryTheWulf "HarryTheWulf (1 commits)")[![ianmustafa](https://avatars.githubusercontent.com/u/5209746?v=4)](https://github.com/ianmustafa "ianmustafa (1 commits)")[![PanovAlexey](https://avatars.githubusercontent.com/u/15037622?v=4)](https://github.com/PanovAlexey "PanovAlexey (1 commits)")[![pavinthan](https://avatars.githubusercontent.com/u/13897936?v=4)](https://github.com/pavinthan "pavinthan (1 commits)")[![DanieliMi](https://avatars.githubusercontent.com/u/31039652?v=4)](https://github.com/DanieliMi "DanieliMi (1 commits)")

---

Tags

laravelpdfmpdf

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/peripteraptos-laravel-pdf/health.svg)](https://phpackages.com/packages/peripteraptos-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)
