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

ActivePhp-bundle[PDF &amp; Document Generation](/categories/documents)

gocanto/laravel-simple-pdf
==========================

Simple laravel PDF generator.

0.0.4(6y ago)2253MITPHPPHP ^7.2CI failing

Since Jun 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/gocanto/laravel-simple-pdf)[ Packagist](https://packagist.org/packages/gocanto/laravel-simple-pdf)[ Docs](https://github.com/gocanto/laravel-simple-pdf)[ RSS](/packages/gocanto-laravel-simple-pdf/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (18)Versions (5)Used By (0)

About it
--------

[](#about-it)

[![Total Downloads](https://camo.githubusercontent.com/ed3c8df5da5aec1b63dc1e17c5cf8d0460ab9559f65f8c16433e9d1b922ae3c4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f63616e746f2f6c61726176656c2d73696d706c652d7064662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gocanto/laravel-simple-pdf)[![Latest Stable Version](https://camo.githubusercontent.com/8edff1ea64176a0175698c54a7ebefc1d5fca72c04679f3b9cd25daae41cdb00/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f676f63616e746f2f6c61726176656c2d73696d706c652d7064662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gocanto/laravel-simple-pdf)[![Build status](https://camo.githubusercontent.com/77ae6500c329f2d26cd6d61c942306051a890a1b148616fb3d6611ba4f22a0a3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f676f63616e746f2f6c61726176656c2d73696d706c652d7064662f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gocanto/laravel-simple-pdf)

This library is a minimalist on demand and `immutable PDF generator` for Laravel. It aims to keep a small friction once you need to generate a printable file using a intuitive public API.

Simple PDF is shipped with a default template that you will be able to use to frame your next PDF files. You can see its layout [here](https://github.com/gocanto/laravel-simple-pdf/blob/master/resources/views/templates/default.blade.php)

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

[](#installation)

This library uses [Composer](https://getcomposer.org) to manage its dependencies. So, before using it, make sure you have it installed in your machine. Once you have done this, you will be able to pull this library in by typing the following command in your terminal.

```
composer require gocanto/laravel-simple-pdf

```

Default template implementation
-------------------------------

[](#default-template-implementation)

Using the default template is the easiest way to get started. Like so:

```
use Gocanto\SimplePDF\Builder;
use Gocanto\SimplePDF\TemplateContext;

Route::get('default-template', function (Builder $builder) {

    $context = TemplateContext::make([
        'title' => 'foo',
        'name' => 'bar',
        'content' => 'Some amazing content!',
    ]);

    $builder->make($context);

    return $builder->render();
});
```

***What's going on here ?***

- First of all, we imported the `Builder` and the `Template Context` objects; you can think about them as the manager to generate your PDF files. For instance, the `Builder`is the one on charge of creating the `Stream File` we will be rendering on demand while the another one holds the data to be display within the default template.
- Second of all, we created the `TemplateContext` object with the desired data to be shown in our PDF file. The context object is a simple value object that holds some handy methods to manipulate the given array within our blade files. [See more](https://github.com/gocanto/laravel-simple-pdf/blob/master/src/TemplateContext.php)
- Lastly, we invoke the `make` method passing in our context object and finish by returning with the `render` functionality.

Custom template implementation
------------------------------

[](#custom-template-implementation)

This implementation is done out of the same API, but it has a bit of configuration on the top. Like so:

```
use Gocanto\SimplePDF\Builder;
use Gocanto\SimplePDF\TemplateContext;

Route::get('custom-template', function (Builder $builder) {

    $context = TemplateContext::make([
        'title' => 'foo',
        'name' => 'bar',
        'content' => 'Some amazing content!',
    ]);

    $builder->addLocation(resource_path('views/home'));
    $new = $builder->withTemplate('home');
    $new->make($context);

    return $new->render();
});
```

As you can see, the first `three steps` are the same as the default implementation, so there is no need to explain further on this regard. Now, we need to clarify the differences on its setup.

- First of all, we tell the builder about our templates root folder by invoking the `addLocation` method. This way, we will be able to have a views root folder to keep our different templates.
- Second of all, we will register the custom templates by calling the `withTemplate` method. Please, do bear in account this is an immutable method, therefore, we will have a new `Builder` instance as result.
- Lastly, we will call the `make` and `render` method in the same way we did with the default template above.

Features
--------

[](#features)

- Multi templates ability.
- The state is immutable, meaning all the withers as `withStream`, `withTemplate` and `withHeaders` methods will return a new instance of the `Builder`.
- The exported stream is expose for custom manipulations, meaning you can pass a call back to the render method to manipulate the given stream before rendering time. Like so:

```
use Psr\Http\Message\StreamInterface;

$new->render(function (StreamInterface $stream) {
    //do something amazing with the stream
    echo $stream->getContents();
});
```

TO DO
-----

[](#to-do)

- (Gus) Allow rendered HTML or Blades files template as part of the `TemplateContext` content field.
- (interested?) Allow more engines like twig.
- (interested?) Make it framework agnostic.

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

[](#contributing)

Please feel free to fork this package and contribute by submitting a pull request to enhance its functionality.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/gocanto/laravel-simple-pdf/blob/master/LICENSE.md) for more information.

How can I thank you?
--------------------

[](#how-can-i-thank-you)

Why not star the github repo and share the link for this repository on Twitter?

Don't forget to [follow me on twitter](https://twitter.com/gocanto)!

Thanks!

Gustavo Ocanto.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.8% 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 ~0 days

Total

4

Last Release

2525d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5246059?v=4)[Gus](/maintainers/gocanto)[@gocanto](https://github.com/gocanto)

---

Top Contributors

[![gocanto](https://avatars.githubusercontent.com/u/5246059?v=4)](https://github.com/gocanto "gocanto (23 commits)")[![kant](https://avatars.githubusercontent.com/u/32717?v=4)](https://github.com/kant "kant (1 commits)")

---

Tags

generatorlaravelpdfphpphplaravelpdfgenerator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

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

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[consoletvs/invoices

Generate PDF invoices for your customers in laravel

455275.5k](/packages/consoletvs-invoices)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)

PHPackages © 2026

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