PHPackages                             rezgui/laravel-mpdf-dz - 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. rezgui/laravel-mpdf-dz

ActiveLibrary[Payment Processing](/categories/payments)

rezgui/laravel-mpdf-dz
======================

Laravel MPdf : Easily generate PDF files with arabic support

1.0.0(2y ago)02.7kMITPHPPHP ^7.4|^8.0

Since Aug 10Pushed 2y ago1 watchersCompare

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

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

Laravel Mpdf: Generate PDF Files with ease.
===========================================

[](#laravel-mpdf-generate-pdf-files-with-ease)

Easily generate PDF files using [Laravel's Blade templates](https://laravel.com/docs/blade) and the [MPDF library](https://mpdf.github.io/) with arabic support. This package has forked from carlos-meneses/laravel-mpdf.

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

[](#installation)

Run this composer command in your laravel application:

```
composer require rezgui/laravel-mpdf-dz

```

Important Notes:
----------------

[](#important-notes)

- Always check the [official MPDF documentation](https://mpdf.github.io/)
- mPDF will timeout on [fetching external HTTP resources](https://github.com/mpdf/mpdf#known-server-caveats) when using single-threaded servers such as `php -S` or `artisan serve`. Use a proper webserver for full functionality.

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

```
'providers' => [
    // ...
    Rezgui\LaravelMpdfDz\LaravelMpdfDzServiceProvider::class
]
```

```
'aliases' => [
    // ...
    'PDF' => Rezgui\LaravelMpdfDz\Facades\LaravelMpdfDz::class
]
```

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

[](#basic-usage)

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

```
//....

use PDF;

class RapportController extends Controller
{
    public function viewPdf()
    {
        $data = [
            'country' => 'Algeria',
            'town'    => 'Biskra'
        ];

        $pdf = PDF::loadView('pdf.document', $data);

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

}
```

```

    Rapport

        {{ $country }}

        {{ $town }}

```

Config
------

[](#config)

You can use a custom file to overwrite the default configuration. Just execute `php artisan vendor:publish --tag=mpdf-config` or create `config/pdf.php` and add this:

```
return [
    'mode'                       => '',
    'format'                     => 'A4',
    'default_font_size'          => '12',
    'default_font'               => 'sans-serif',
    'margin_left'                => 10,
    'margin_right'               => 10,
    'margin_top'                 => 10,
    'margin_bottom'              => 10,
    'margin_header'              => 0,
    'margin_footer'              => 0,
    'orientation'                => 'P',
    'title'                      => 'Laravel mPDF Dz',
    'author'                     => '',
    'watermark'                  => '',
    'show_watermark'             => false,
    'show_watermark_image'       => false,
    'watermark_font'             => 'sans-serif',
    'display_mode'               => 'fullpage',
    'watermark_text_alpha'       => 0.1,
    'watermark_image_path'       => '',
    'watermark_image_alpha'      => 0.2,
    'watermark_image_size'       => 'D',
    'watermark_image_position'   => 'P',
    'custom_font_dir'            => '',
    'custom_font_data'           => [],
    'auto_language_detection'    => false,
    'temp_dir'                   => storage_path('app'),
    'pdfa'                       => false,
    'pdfaauto'                   => false,
    'use_active_forms'           => false,
];
```

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

```
// ...

PDF::loadView('pdf', $data, [], [
    'title' => 'Another Title',
    'margin_top' => 0
])->save($pdfFilePath);
```

Get instance your Mpdf
----------------------

[](#get-instance-your-mpdf)

You can access all mpdf methods through the mpdf instance with `getMpdf` method.

```
use PDF;

$pdf = PDF::loadView('pdf.document', $data);
$pdf->getMpdf()->AddPage(/*...*/);
```

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_dir'  => base_path('resources/fonts/'), // don't forget the trailing slash!
    'custom_font_data' => [
        'examplefont' => [ // must be lowercase and snake_case
            '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;
}
```

Chunk HTML
----------

[](#chunk-html)

For big HTML you might get `Uncaught Mpdf\MpdfException: The HTML code size is larger than pcre.backtrack_limit xxx` error, or you might just get [empty or blank result](https://mpdf.github.io/troubleshooting/known-issues.html#blank-pages-or-some-sections-missing). In these situations you can use chunk methods while you added a separator to your HTML:

```
//....
use PDF;
class ReportController extends Controller
{
    public function generate_pdf()
    {
        $data = [
            'foo' => 'hello 1',
            'bar' => 'hello 2'
        ];
        $pdf = PDF::chunkLoadView('', 'pdf.document', $data);
        return $pdf->stream('document.pdf');
    }
}
```

```

    Hello World

        {{ $foo }}

        {{ $bar }}

```

Added Support for the Macroable Trait
-------------------------------------

[](#added-support-for-the-macroable-trait)

You can configure the macro in the `AppServiceProvider` provider file.

```
//...
use Rezgui\LaravelMpdfDz\LaravelMpdfDz;

class AppServiceProvider extends ServiceProvider
{
  //...

    public function boot()
    {
        LaravelMpdfDz::macro('bonjour', function () {
            return "Bonjour, le monde !";
        });
    }

  //...
}
```

Now

```
PDF::loadView(/* ... */)->hello();
```

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

1006d ago

### Community

Maintainers

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

---

Top Contributors

[![rezgui](https://avatars.githubusercontent.com/u/1289096?v=4)](https://github.com/rezgui "rezgui (2 commits)")

---

Tags

phplaravelpdfinvoiceLaravel pdfmpdfarabicdocumentsadobepdf-invoicepdf-documentsrezgui

### Embed Badge

![Health badge](/badges/rezgui-laravel-mpdf-dz/health.svg)

```
[![Health](https://phpackages.com/badges/rezgui-laravel-mpdf-dz/health.svg)](https://phpackages.com/packages/rezgui-laravel-mpdf-dz)
```

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[anam/phantommagick

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

161456.4k2](/packages/anam-phantommagick)[atgp/factur-x

PHP library to manage your Factur-X / ZUGFeRD 2.0 PDF invoices files

138825.5k3](/packages/atgp-factur-x)[torgodly/html2media

Html2Media is a versatile Laravel package that allows users to convert HTML content into high-quality PDFs with options for either downloading or triggering a print dialog. Ideal for generating documents, invoices, and reports, this package includes configurable settings for file name, page orientation, format, margins, and scale. Html2Media also provides seamless integration with Filament actions, enabling dynamic content rendering in modals and customizable output previews. Whether you need to save a PDF or send it directly to the printer, Html2Media simplifies the process with robust, flexible features.

4532.5k1](/packages/torgodly-html2media)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)

PHPackages © 2026

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