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

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

mralston/pdf
============

Laravel wrapper for generating PDF files using headless Chrome/Chromium

v1.0.4(1y ago)7433↓50%MITPHPPHP ^7.4.15|^8.0

Since Jul 31Pushed 1y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

PDF
===

[](#pdf)

Introduction
------------

[](#introduction)

A convenient way to generate PDF files in Laravel using a headless Chrome/Chromium instance.

This package is a wrapper around [chrome-php/chrome](https://packagist.org/packages/chrome-php/chrome).

Config
------

[](#config)

You may publish the config file as follows:

```
php artisan vendor:publish --tag=pdf-config
```

Usage
-----

[](#usage)

Here are now the basic functions of the wrapper library work:

```
use Mralston\Pdf\Pdf;

// Can be instantiated using a view
$pdf = Pdf::fromView('path.to.blade-template', [
    'variable1' => $value1,
    'variable2' => $value2,
]);

// Or with HTML
$html = 'test...';

$pdf = Pdf::fromHtml($html);

// Or from a URL
$pdf = Pdf::fromUrl('https://www.google.com/');

// The path to the Chrome executable can be adjusted (defaults to /usr/bin/chromium)
// This can also be done using the CHROME_BINARY environment variable
$pdf->setChromeBinary('/bin/chrome');

// Options can be passed to the Chrome rendering engine
$pdf->setOptions([
    'landscape' => true,
    'scale' => 0.8,
]);

// It can be instructed to emulate PhantomJS (your mileage may vary)
$pdf->emulatePhantomJs();

// The timeout can be adjusted for slow pages (defaults to 30 seconds)
$pdf->setTimeout(60);

// The PDF can be saved to disk
$pdf->save('/path/to/output.pdf');

// Or streamed to the browser
return $pdf->stream();

// Or sent to the browser as a download
return $pdf->download($filename);
```

Putting it all together into a (somewhat) real-world example:

```
use Mralston\Pdf\Pdf;
use App\Models\Invoice;
use Illuminate\Http\Response;

class InvoiceController
{
    public function downloadPdf(Invoice $invoice, string $filename): Response
    {
        return Pdf::fromView('invoices.show', [
            'invoice' => $invoice,
        ])
        ->setChromeBinary('/usr/bin/chrome')
        ->setOptions([
            'landscape' => true,
            'scale' => 0.9,
        ])
        ->setTimeout(60)
        ->download($filename);
    }
}
```

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

[](#security-vulnerabilities)

Please [e-mail security vulnerabilities directly to me](mailto:matt@mralston.co.uk).

Licence
-------

[](#licence)

PDF is open-sourced software licenced under the [MIT license](LICENSE.md).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance48

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~159 days

Total

5

Last Release

383d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/248387?v=4)[Matt](/maintainers/mralston)[@mralston](https://github.com/mralston)

---

Top Contributors

[![mralston](https://avatars.githubusercontent.com/u/248387?v=4)](https://github.com/mralston "mralston (6 commits)")

---

Tags

laravelpdfmralston

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

7.3k87.6M278](/packages/barryvdh-laravel-dompdf)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

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

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[lucasromanojf/laravel5-pdf

Provides the HTML2PDF functionality using the wkhtmltopdf library (Laravel 5)

1271.8k](/packages/lucasromanojf-laravel5-pdf)[eve/pdf-converter

Laravel package to convert HTML to PDF, supporting multiple drivers.

114.1k](/packages/eve-pdf-converter)

PHPackages © 2026

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