PHPackages                             farhan/laravel-dompdf - 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. farhan/laravel-dompdf

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

farhan/laravel-dompdf
=====================

A DOMPDF Wrapper for Laravel

043PHP

Since Apr 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/farhanbashir06/laravel-dompdf)[ Packagist](https://packagist.org/packages/farhan/laravel-dompdf)[ RSS](/packages/farhan-laravel-dompdf/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

DOMPDF Wrapper for Laravel
--------------------------

[](#dompdf-wrapper-for-laravel)

### Laravel wrapper for [Dompdf HTML to PDF Converter](https://github.com/dompdf/dompdf)

[](#laravel-wrapper-for-dompdf-html-to-pdf-converter)

[![Tests](https://github.com/barryvdh/laravel-dompdf/workflows/Tests/badge.svg)](https://github.com/barryvdh/laravel-dompdf/workflows/Tests/badge.svg)

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

[](#installation)

### Laravel

[](#laravel)

Require this package in your composer.json and update composer. This will download the package and the dompdf + fontlib libraries also.

```
composer require barryvdh/laravel-dompdf

```

### Lumen

[](#lumen)

After updating composer add the following lines to register provider in `bootstrap/app.php`

```
$app->register(\Barryvdh\DomPDF\ServiceProvider::class);

```

To change the configuration, copy the config file to your config folder and enable it in `bootstrap/app.php`:

```
$app->configure('dompdf');

```

Using
-----

[](#using)

You can create a new DOMPDF instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download.

```
    $pdf = App::make('dompdf.wrapper');
    $pdf->loadHTML('Test');
    return $pdf->stream();
```

Or use the facade:

```
    use Barryvdh\DomPDF\Facade\Pdf;

    $pdf = PDF::loadView('pdf.invoice', $data);
    return $pdf->download('invoice.pdf');
```

You can chain the methods:

```
    return PDF::loadFile(public_path().'/myfile.html')->save('/path-to/my_stored_file.pdf')->stream('download.pdf');
```

You can change the orientation and paper size, and hide or show errors (by default, errors are shown when debug is on)

```
    PDF::loadHTML($html)->setPaper('a4', 'landscape')->setWarnings(false)->save('myfile.pdf')
```

If you need the output as a string, you can get the rendered PDF with the output() function, so you can save/output it yourself.

Use `php artisan vendor:publish` to create a config file located at `config/dompdf.php` which will allow you to define local configurations to change some settings (default paper etc). You can also use your ConfigProvider to set certain keys.

### Configuration

[](#configuration)

The defaults configuration settings are set in `config/dompdf.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="Barryvdh\DomPDF\ServiceProvider"
```

You can still alter the dompdf options in your code before generating the pdf using this command:

```
    PDF::setOptions(['dpi' => 150, 'defaultFont' => 'sans-serif']);
```

Available options and their defaults:

- **rootDir**: "{app\_directory}/vendor/dompdf/dompdf"
- **tempDir**: "/tmp" *(available in config/dompdf.php)*
- **fontDir**: "{app\_directory}/storage/fonts/" *(available in config/dompdf.php)*
- **fontCache**: "{app\_directory}/storage/fonts/" *(available in config/dompdf.php)*
- **chroot**: "{app\_directory}" *(available in config/dompdf.php)*
- **logOutputFile**: "/tmp/log.htm"
- **defaultMediaType**: "screen" *(available in config/dompdf.php)*
- **defaultPaperSize**: "a4" *(available in config/dompdf.php)*
- **defaultFont**: "serif" *(available in config/dompdf.php)*
- **dpi**: 96 *(available in config/dompdf.php)*
- **fontHeightRatio**: 1.1 *(available in config/dompdf.php)*
- **isPhpEnabled**: false *(available in config/dompdf.php)*
- **isRemoteEnabled**: true *(available in config/dompdf.php)*
- **isJavascriptEnabled**: true *(available in config/dompdf.php)*
- **isHtml5ParserEnabled**: false *(available in config/dompdf.php)*
- **isFontSubsettingEnabled**: false *(available in config/dompdf.php)*
- **debugPng**: false
- **debugKeepTemp**: false
- **debugCss**: false
- **debugLayout**: false
- **debugLayoutLines**: true
- **debugLayoutBlocks**: true
- **debugLayoutInline**: true
- **debugLayoutPaddingBox**: true
- **pdfBackend**: "CPDF" *(available in config/dompdf.php)*
- **pdflibLicense**: ""
- **adminUsername**: "user"
- **adminPassword**: "password"

### Tip: UTF-8 support

[](#tip-utf-8-support)

In your templates, set the UTF-8 Metatag:

```

```

### Tip: Page breaks

[](#tip-page-breaks)

You can use the CSS `page-break-before`/`page-break-after` properties to create a new page.

```

.page-break {
    page-break-after: always;
}

Page 1

Page 2

```

### License

[](#license)

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

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/88aaa9c1239781a11b95a0ed3b73545b7614ea6b65d1725f7b12be7ac2f36b8c?d=identicon)[farhanbashir06](/maintainers/farhanbashir06)

---

Top Contributors

[![farhanbashir06](https://avatars.githubusercontent.com/u/59952030?v=4)](https://github.com/farhanbashir06 "farhanbashir06 (3 commits)")

### Embed Badge

![Health badge](/badges/farhan-laravel-dompdf/health.svg)

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

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.2k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M100](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M128](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

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