PHPackages                             ihorhnatchuk/laravel-browsershot - 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. ihorhnatchuk/laravel-browsershot

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

ihorhnatchuk/laravel-browsershot
================================

Browsershot Laravel wrapper to generate PDF files and Screenshots using Headless Chrome

03.4kPHP

Since Aug 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ihorhnatchuk/laravel-browsershot)[ Packagist](https://packagist.org/packages/ihorhnatchuk/laravel-browsershot)[ RSS](/packages/ihorhnatchuk-laravel-browsershot/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

[Browsershot](https://github.com/spatie/browsershot) wrapper for Laravel 5
==========================================================================

[](#browsershot-wrapper-for-laravel-5)

This package takes advantage of Google Chrome's Headless mode to take screenshots and generate PDFs from websites, views and raw html

Requirements
============

[](#requirements)

- [Node](https://nodejs.org/) 7.6.0 or higher
- [Google Chrome](https://www.google.com/chrome/)
- [Puppeteer Node library](https://github.com/GoogleChrome/puppeteer).

You can install Puppeteer in your project via NPM:

```
npm install puppeteer
```

Or you could opt to just install it globally

```
npm install puppeteer --global
```

On a [Forge](https://forge.laravel.com) provisioned Ubuntu 16.04 server you can install the latest stable version of Chrome like this:

```
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
sudo npm install --global --unsafe-perm puppeteer
sudo chmod -R o+rx /usr/lib/node_modules/puppeteer/.local-chromium
```

Installation
============

[](#installation)

Install the package through composer

```
composer require IhorHnatchuk/laravel-browsershot
```

After the package is installed the service provider will be automatically discovered and two new Facades `PDF` and `Screenshot` will be available

Usage
=====

[](#usage)

The recommended way to use this package is through its Facades

PDF
---

[](#pdf)

### Generating a PDF from a view and returning it inline

[](#generating-a-pdf-from-a-view-and-returning-it-inline)

```

  use IhorHnatchuk\Browsershot\Facades\PDF;

  ...

  return PDF::loadView('view.name', $data)
            ->inline();

```

You can chain all the methods available in the [browsershot master library](https://github.com/spatie/browsershot)

### Returning the PDF as a download

[](#returning-the-pdf-as-a-download)

```
  use IhorHnatchuk\Browsershot\Facades\PDF;

  ...

  return PDF::loadView('view.name', $data)
            ->margins(20, 0, 0, 20)
            ->download();
```

You can pass the custom file name and additional headers the response will have to the `inline` and `download` methods like

```
  PDF::loadHtml('Awesome PDF')
      ->download('myawesomepdf.pdf', [
        'Authorization' => 'token'
      ]);
```

### Persisting PDF to disk

[](#persisting-pdf-to-disk)

If you would like to save the generated pdf file to your storage disk you can call the `store` or `storeAs` method

```
  $pdfStoredPath = PDF::loadUrl('https://google.com')
                      ->store('pdfs/')
```

This will use the default storage driver to store the pdf in the `pdfs/` folder giving it a unique name. If you would like to specify the name you can call de `storeAs` method

```
  $pdfStoredPath = PDF::loadUrl('https://google.com')
                      ->storeAs('pdfs/', 'google.pdf')
```

Screenshots
-----------

[](#screenshots)

Screenshots are created the same way as PDFs just change the facade to `Screenshot`

### Generating screenshots as JPG/JPEG

[](#generating-screenshots-as-jpgjpeg)

By default screenshots will be taken as PNG format if you would like to use JPG instead call the `useJPG()` method

```
use IhorHnatchuk\Browsershot\Facades\Screenshot;

Screenshot::loadView('view.name', $data)
           ->useJPG()
           ->margins(20, 0, 0, 20)
           ->download();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

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/1d24d679d95e12f8dc6126e2997af40ca74fe6f6200debbfd99585fb7c27df57?d=identicon)[ihorhnatchuk](/maintainers/ihorhnatchuk)

---

Top Contributors

[![ihorhnatchuk](https://avatars.githubusercontent.com/u/30617773?v=4)](https://github.com/ihorhnatchuk "ihorhnatchuk (7 commits)")

### Embed Badge

![Health badge](/badges/ihorhnatchuk-laravel-browsershot/health.svg)

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

###  Alternatives

[phpoffice/phpspreadsheet

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

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

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/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.6M131](/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)
