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

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

givemelib/laravel-pdf
=====================

Laravel PDF - for generating pdf invice or documents.

1.2.2(5y ago)1131MITPHPPHP &gt;=5.4.0

Since Jul 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/givemelib/laravel-pdf)[ Packagist](https://packagist.org/packages/givemelib/laravel-pdf)[ Docs](http://givemelib.rf.gd)[ RSS](/packages/givemelib-laravel-pdf/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (2)Versions (5)Used By (0)

[![PHP Composer](https://github.com/givemelib/laravel-pdf/workflows/PHP%20Composer/badge.svg?branch=master)](https://github.com/givemelib/laravel-pdf/workflows/PHP%20Composer/badge.svg?branch=master)

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

```

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

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

```
'aliases' => [
	// ...
	'PDF' => GiveMeLib\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="GiveMeLib\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 PDF;

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

or

```
use GiveMeLib\LaravelPDF\PDF;

function generate_pdf() {
	$data = [
		'foo' => 'bar'
	];
	$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:

```
    $font_data = 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($font_data, 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

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

2120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a48a064de4b3f8a03d0b552570ba2fa22701bab89243fe346f90d4ed320149b?d=identicon)[givemelib](/maintainers/givemelib)

---

Top Contributors

[![givemelib](https://avatars.githubusercontent.com/u/68523271?v=4)](https://github.com/givemelib "givemelib (17 commits)")

---

Tags

laravelpdfLaravel pdfadobepdf-invoicepdf-documents

### Embed Badge

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

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

PHPackages © 2026

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