PHPackages                             zanysoft/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. [Payment Processing](/categories/payments)
4. /
5. zanysoft/laravel-pdf

ActiveLibrary[Payment Processing](/categories/payments)

zanysoft/laravel-pdf
====================

Laravel PDF - for generating pdf invoice or documents with mPDF wrapper.

v3.1.0(3mo ago)752.9k↓14.9%6[2 issues](https://github.com/zanysoft/laravel-pdf/issues)[1 PRs](https://github.com/zanysoft/laravel-pdf/pulls)MITPHPPHP ^8.0CI passing

Since Feb 20Pushed 3mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (12)Used By (0)

Laravel PDF: PDF generator for Laravel
======================================

[](#laravel-pdf-pdf-generator-for-laravel)

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

Contents
--------

[](#contents)

- [Installation Guide](#installation-guide)
- [Configuration](#configuration)
- [Basic Usage](#basic-usage)
- [Headers and Footers](#headers-and-footers)
- [Included Fonts](#included-fonts)
- [Custom Fonts](#custom-fonts)
- [Set Protection](#set-protection)
- [Documentation](#documentation)

### Installation Guide

[](#installation-guide)

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

```
composer require zanysoft/laravel-pdf

```

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

```
'providers' => [
	// ...
	ZanySoft\LaravelPDF\PdfServiceProvider::class
]
```

```
'aliases' => [
	// ...
	'PDF' => ZanySoft\LaravelPDF\Facades\PDF::class
]
```

### Configuration

[](#configuration)

The defaults configuration settings are set in `config/pdf.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command:

```
php artisan vendor:publish --provider="ZanySoft\LaravelPDF\PdfServiceProvider"

```

### 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 ZanySoft\LaravelPDF\Facades\PDF;

    $data = ['foo' => 'bar'];
    $pdf = PDF::make('document.pdf');
    $pdf->loadView('pdf.document', $data);

    return $pdf->stream();
```

or

```
    use ZanySoft\LaravelPDF\PDF;

    $pdf = new PDF();
    $pdf->loadView('pdf.document', $data);

    return $pdf->stream('document.pdf');
```

If you want to generate from html content:

```
    $content = "Hello this is first pdf file."
    $pdf->loadHTML($content);

    return $pdf->stream('document.pdf');
```

If you want to generate from files:

```
    $file = "file.txt"
    $pdf->loadFile($file);

    return $pdf->stream('document.pdf');
```

If you want download pdf file:

```
    return $pdf->embed('document.pdf');
```

If you want to save pdf to server:

```
    return $pdf->save('with-complete-path/document.pdf');
```

If you want add pdf file as attachment to email:

```
    return $pdf->embed('document.pdf');
```

### 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!
    ];
```

And then:

```
    $fontdata = array(
        '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.
    );

    $pdf->addCustomFont($fontdata, true);
    // If your font file is unicode and "OpenType Layout" then set true. Default value is false.
```

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 few permissions: `'copy'`, `'print'`, `'modify'`, `'annot-forms'`, `'fill-forms'`, `'extract'`, `'assemble'`, `'print-highres'`.

```
use PDF;

function generate_pdf() {
    $data = [
        'foo' => 'bar'
    ];
    $pdf = PDF::make();
    $pdf->SetProtection(['copy', 'print'], 'user_pass', 'owner_pass')
    $pdf->loadView('pdf.document', $data);

    return $pdf->stream('document.pdf');
}
```

Find more information to `SetProtection()` here:

### Documentation

[](#documentation)

Visit this link for more options and settings:

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance74

Regular maintenance activity

Popularity37

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~336 days

Recently: every ~302 days

Total

11

Last Release

104d ago

Major Versions

v1.0.4 → v2.0.02021-04-14

v2.0.4 → v3.0.02024-12-18

PHP version history (4 changes)1.0.1.x-devPHP &gt;=5.4.0

v1.0.4PHP ^7.1 || ^8

v2.0.1PHP ^7.1 || ^8.0

v2.0.3PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77060551?v=4)[Mubashar Ahmad (مبشر احمد)](/maintainers/mubasharahmad)[@MubasharAhmad](https://github.com/MubasharAhmad)

---

Top Contributors

[![zanysoft](https://avatars.githubusercontent.com/u/2682072?v=4)](https://github.com/zanysoft "zanysoft (7 commits)")[![mubashar-mtp](https://avatars.githubusercontent.com/u/144340553?v=4)](https://github.com/mubashar-mtp "mubashar-mtp (1 commits)")

---

Tags

html-to-pdfhtml-to-pdf-phplaravellaravel-pdfmpdfpdfpdf-converterpdf-documentpdf-filespdf-generationphplaravelpdfinvoiceLaravel pdfmpdfdocumentsadobepdf-invoicepdf-documents

### Embed Badge

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

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

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.6k1.5M5](/packages/laraveldaily-laravel-invoices)[anam/phantommagick

PhantomMagick provides a simple API to ease the process of converting HTML to PDF or images

160465.5k2](/packages/anam-phantommagick)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3827.1k](/packages/linkxtr-laravel-qrcode)

PHPackages © 2026

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