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

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

danielboendergaard/phantom-pdf
==============================

A Package for generating PDF files using PhantomJS

v3.1.0(2y ago)72467.9k↓19.9%27MITPHPPHP &gt;=8.1

Since May 26Pushed 2y ago6 watchersCompare

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

READMEChangelog (7)Dependencies (2)Versions (31)Used By (0)

Phantom PDF
===========

[](#phantom-pdf)

A Package for generating PDF files using PhantomJS. The package is framework agnostic, but provides integration with Laravel.

Notice: This package only ships with the 64-bit Linux version of PhantomJS. If you want to use it with another version you can reference it in the configuration.

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

[](#installation)

Run `composer require danielboendergaard/phantom-pdf`

### Usage

[](#usage)

```
$pdf = new PdfGenerator;

// Set a writable path for temporary files
$pdf->setStoragePath('storage/path');

// Saves the PDF as a file (optional)
$pdf->saveFromView($html, 'filename.pdf');

// Returns a Symfony\Component\HttpFoundation\BinaryFileResponse
return $pdf->createFromView($html, 'filename.pdf');
```

### PhantomJS Version

[](#phantomjs-version)

This package uses PhantomJS 1.9.8 x64 which is included in the package. If you want to use another version it's easy.

```
$pdf->setBinaryPath('/some/path/phantomjs');
```

### Customizing the conversion script

[](#customizing-the-conversion-script)

If you want to use another script to execute with PhantomJS, this it how you do it.

```
$pdf->useScript('`/path/to/script');
```

Laravel integration
-------------------

[](#laravel-integration)

### Installation

[](#installation-1)

#### For Laravel 5.5 the package supports auto discovery and don't need any configuration.

[](#for-laravel-55-the-package-supports-auto-discovery-and-dont-need-any-configuration)

For Laravel 4, use the 0.10.0 branch.

Add `LaravelServiceProvider` in the `providers` array in `config/app.php`

```
'providers' => [
  PhantomPdf\Laravel\LaravelServiceProvider::class,
]
```

#### Facades (optional)

[](#facades-optional)

Add the facade to the `aliases` array in `app/config/app.php` (optional)

```
'aliases' => [
  'PDF' => PhantomPdf\Laravel\PDFFacade::class,
]
```

### Usage

[](#usage-1)

```
class SampleController extends Controller
{
  public function index()
  {
    return PDF::createFromView(view('index'), 'filename.pdf');
  }

  // Save the pdf to disk
  public function save()
  {
      PDF::saveFromView(view('index'), 'path/filename.pdf');
  }

  // Usa via injection
  public function foo(PdfGenerator $pdf)
  {
    return $pdf->createFromView(view('path'), 'filename.pdf');
  }
}
```

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 91.7% 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 ~123 days

Recently: every ~366 days

Total

30

Last Release

789d ago

Major Versions

v0.10.0 → v1.0.02016-04-28

v1.4.0 → v2.0.02020-03-16

v2.0.1 → v3.0.02022-06-28

PHP version history (4 changes)v0.0.1PHP &gt;=5.4.0

v2.0.0PHP ^7.2.5

v2.0.1PHP ^7.2.5|^8.0

v3.0.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![danielboendergaard](https://avatars.githubusercontent.com/u/314877?v=4)](https://github.com/danielboendergaard "danielboendergaard (55 commits)")[![MacTwister](https://avatars.githubusercontent.com/u/1853847?v=4)](https://github.com/MacTwister "MacTwister (1 commits)")[![matthijs110](https://avatars.githubusercontent.com/u/4161158?v=4)](https://github.com/matthijs110 "matthijs110 (1 commits)")[![milhouse1337](https://avatars.githubusercontent.com/u/326740?v=4)](https://github.com/milhouse1337 "milhouse1337 (1 commits)")[![przemekperon](https://avatars.githubusercontent.com/u/169778?v=4)](https://github.com/przemekperon "przemekperon (1 commits)")[![rumeau](https://avatars.githubusercontent.com/u/2340790?v=4)](https://github.com/rumeau "rumeau (1 commits)")

---

Tags

laravelpdfhtml

### Embed Badge

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

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

###  Alternatives

[mostafaznv/pdf-optimizer

PDF optimization tool for PHP and Laravel applications

170125.8k](/packages/mostafaznv-pdf-optimizer)[nilgems/laravel-textract

A Laravel package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring "npm textract".

195.2k](/packages/nilgems-laravel-textract)[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)
