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

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

spatie/laravel-pdf
==================

Create PDFs in Laravel apps

2.4.0(2mo ago)9963.4M—1.2%9012MITPHPPHP ^8.2CI passing

Since Dec 26Pushed 1mo ago12 watchersCompare

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

READMEChangelog (10)Dependencies (48)Versions (43)Used By (12)

 [   ![Logo for laravel-pdf](https://camo.githubusercontent.com/310c53d9e37a32345b5b7e1c59eabd0e998e4f7828dcc12d6eda46bdd1d9caf4/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c61726176656c2d7064662f68746d6c2f6c696768742e77656270)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-pdf)Create PDFs in Laravel apps
===========================

[](#create-pdfs-in-laravel-apps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/eb4451b8f7caf7ea5c959a13fc27356ae4734b2e4b4681bf1f561cdc16a69b2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d7064662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-pdf)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1625b5b7a92f1abfa5cb7af648aa5e3b1f20adc5dc7482500d763be6dc87b836/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d7064662f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-pdf/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a6dd92a8456fe510854a164ec7c54def99a738e08a742958e3c719622f132aac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d7064662f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-pdf/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/46231fac7df06cfbc7a5c613a227117b1206aa6abc0b6e7e8153b7d51cd2c1e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d7064662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-pdf)

This package provides a simple way to create PDFs in Laravel apps. It supports multiple drivers: [Browsershot](https://spatie.be/docs/browsershot) (Chromium), [Gotenberg](https://gotenberg.dev) (Docker-based), [Cloudflare Browser Rendering](https://developers.cloudflare.com/browser-rendering/), [WeasyPrint](https://doc.courtbouillon.org/weasyprint/stable/) (Python-based), and [DOMPDF](https://github.com/dompdf/dompdf) (pure PHP). You can use modern CSS features like grid and flexbox with the Chromium-based drivers, use WeasyPrint for excellent CSS Paged Media support, or choose DOMPDF for a zero-dependency setup.

Here's a quick example:

```
use Spatie\LaravelPdf\Facades\Pdf;

Pdf::view('pdfs.invoice', ['invoice' => $invoice])
    ->format('a4')
    ->save('invoice.pdf')
```

This will render the Blade view `pdfs.invoice` with the given data and save it as a PDF file.

You can also return the PDF as a response from your controller:

```
use Spatie\LaravelPdf\Facades\Pdf;

class DownloadInvoiceController
{
    public function __invoke(Invoice $invoice)
    {
        return Pdf::view('pdfs.invoice', ['invoice' => $invoice])
            ->format('a4')
            ->name('your-invoice.pdf');
    }
}
```

You can use also test your PDFs:

```
use Spatie\LaravelPdf\Facades\Pdf;

it('can render an invoice', function () {
    Pdf::fake();

    $invoice = Invoice::factory()->create();

    $this->get(route('download-invoice', $invoice))
        ->assertOk();

    Pdf::assertRespondedWithPdf(function (PdfBuilder $pdf) {
        return $pdf->contains('test');
    });
});
```

Laravel Boost
-------------

[](#laravel-boost)

This package ships with a [Laravel Boost](https://laravel.com/docs/12.x/boost) skill. After installing the package, run `php artisan boost:install` to register the skill. This will help AI agents in your project generate correct PDF code.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/9b85c24f6587b06e227bbdb00eb7dca971669a1311d2a94c2ea966d25c03cf09/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d7064662e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-pdf)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Documentation
-------------

[](#documentation)

All documentation is available [on our documentation site](https://spatie.be/docs/laravel-pdf).

Testing
-------

[](#testing)

For running the testsuite, you'll need to have Puppeteer installed. Pleaser refer to the Browsershot requirements [here](https://spatie.be/docs/browsershot/v4/requirements). Usually `npm -g i puppeteer` will do the trick.

Additionally, you'll need the `pdftotext` CLI which is part of the poppler-utils package. More info can be found in in the [spatie/pdf-to-text readme](https://github.com/spatie/pdf-to-text?tab=readme-ov-file#requirements). Usually `brew install poppler-utils` will suffice.

Finally run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

69

—

FairBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity68

Solid adoption and visibility

Community40

Growing community involvement

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 69.4% 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 ~23 days

Recently: every ~7 days

Total

35

Last Release

68d ago

Major Versions

0.0.5 → 1.0.02024-01-02

1.9.0 → v2.x-dev2026-02-08

v1.x-dev → 2.1.02026-02-09

PHP version history (2 changes)0.0.1PHP ^8.1

1.1.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (259 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![ArielMejiaDev](https://avatars.githubusercontent.com/u/31971074?v=4)](https://github.com/ArielMejiaDev "ArielMejiaDev (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![A909M](https://avatars.githubusercontent.com/u/119125167?v=4)](https://github.com/A909M "A909M (8 commits)")[![sertxudev](https://avatars.githubusercontent.com/u/22801379?v=4)](https://github.com/sertxudev "sertxudev (7 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (6 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (6 commits)")[![jeffreyvanhees](https://avatars.githubusercontent.com/u/8754630?v=4)](https://github.com/jeffreyvanhees "jeffreyvanhees (6 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (6 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (3 commits)")[![Nathan-Cowin](https://avatars.githubusercontent.com/u/91381012?v=4)](https://github.com/Nathan-Cowin "Nathan-Cowin (3 commits)")[![albertStaalburger](https://avatars.githubusercontent.com/u/797741?v=4)](https://github.com/albertStaalburger "albertStaalburger (2 commits)")[![RVP04](https://avatars.githubusercontent.com/u/8185511?v=4)](https://github.com/RVP04 "RVP04 (2 commits)")[![Seb33300](https://avatars.githubusercontent.com/u/915273?v=4)](https://github.com/Seb33300 "Seb33300 (2 commits)")[![ahme-d](https://avatars.githubusercontent.com/u/9767569?v=4)](https://github.com/ahme-d "ahme-d (2 commits)")[![stevethomas](https://avatars.githubusercontent.com/u/1127412?v=4)](https://github.com/stevethomas "stevethomas (2 commits)")[![vintagesucks](https://avatars.githubusercontent.com/u/13335308?v=4)](https://github.com/vintagesucks "vintagesucks (2 commits)")[![innocenzi](https://avatars.githubusercontent.com/u/16060559?v=4)](https://github.com/innocenzi "innocenzi (2 commits)")

---

Tags

laravelpdfphpspatielaravelLaravel pdf

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[spatie/laravel-onboard

A Laravel package to help track user onboarding steps

808342.9k1](/packages/spatie-laravel-onboard)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)

PHPackages © 2026

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