laravel-enso/pdf

PDF for Laravel Enso
39,496 1
Install
composer require laravel-enso/pdf
Latest Version:2.1.4
PHP:>=7.4
License:MIT
Last Updated:Apr 21, 2026
Links: GitHub  ·  Packagist
Maintainer: aocneanu

PDF

License Stable Downloads PHP Issues Merge Requests

Description

Pdf provides a small Laravel Enso wrapper around Snappy / wkhtmltopdf for generating PDF documents from Blade views.

The package exposes a fluent Pdf service that applies Enso's default page settings, loads a view with data, and then lets the caller inline, download, save, or output the rendered PDF.

It is used across the ecosystem for invoices, orders, delivery notes, stock documents, and other printable documents that need a consistent PDF pipeline.

Installation

Install the package:

composer require laravel-enso/pdf

The package relies on barryvdh/laravel-snappy, which in turn requires a working wkhtmltopdf binary in the target environment.

No additional provider registration is needed beyond Composer's package discovery.

Features

  • Wraps barryvdh/laravel-snappy in a small fluent service.
  • Loads Blade views with arbitrary data before rendering.
  • Streams PDFs inline in the browser.
  • Supports file download responses.
  • Supports saving generated PDFs to disk.
  • Exposes raw PDF output as a string.
  • Ships with Enso defaults for paper size, margins, orientation, and footer pagination.

Usage

Generate a PDF from a Blade view:

use LaravelEnso\Pdf\Services\Pdf;

return (new Pdf())
    ->loadView('documents.order', ['order' => $order])
    ->inline('order.pdf');

Download instead of inlining:

return (new Pdf())
    ->loadView('documents.invoice', ['invoice' => $invoice])
    ->download('invoice.pdf');

Save the generated file:

(new Pdf())
    ->loadView('documents.note', ['model' => $model])
    ->save(storage_path('app/temp/document.pdf'));

Switch to landscape and override options when needed:

$pdf = (new Pdf())
    ->landscape()
    ->setOption('margin-top', 5)
    ->loadView('documents.report', ['report' => $report]);

::: warning Note This package is only a wrapper around Snappy. Rendering still depends on the availability and correctness of the underlying wkhtmltopdf binary in the running environment. :::

API

Contracts

  • LaravelEnso\Pdf\Contracts\GeneratesPdf
  • LaravelEnso\Pdf\Contracts\SavesPdf

GeneratesPdf defines:

  • inline(): Response
  • output(): string

SavesPdf defines:

  • save()

Pdf Service

LaravelEnso\Pdf\Services\Pdf

Public methods:

  • __construct()
  • inline(string $filename = 'document.pdf'): Response
  • output(): string
  • save($filename, $overwrite = false): PdfWrapper
  • download(string $filename): Response
  • landscape(): self
  • setOption(string $option, $value): self
  • loadView(string $view, array $attributes): self

Default options applied in the factory:

  • paper: a4
  • orientation: portrait
  • margin-top: 10
  • margin-left: 5
  • margin-right: 5
  • margin-bottom: 10
  • footer-font-size: 8
  • footer-center: "Page [page] from [toPage]"

Depends On

Framework dependency:

External dependencies:

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

Related Packages

barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

28,101,196 2,756
elibyy/tcpdf-laravel

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

3,080,940 355
lucasromanojf/laravel5-pdf

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

72,577 7
barryvdh/laravel-dompdf

A DOMPDF Wrapper for Laravel

113,736,607 7,285
codedge/laravel-fpdf

Laravel package to include Fpdf. It ships with Fpdf 1.86.

1,976,852 293