Skip to content

Framework integration

NextPDF Laravel

First-class Laravel 12 integration — Facade, responses, and queued generation.

Free · Apache-2.0Laravel ^12.0 · NextPDF ^3.0 · PHP 8.4+

NextPDF Laravel provides first-class Laravel 12 integration for NextPDF. It ships with auto-discovery, a Pdf Facade, streaming download and inline preview responses, queued generation for heavy workloads, and automatic detection of installed extensions (Artisan, Pro). Designed to be Octane-safe and Reverb-compatible out of the box.

How it fits

Built into your workflow

Zero-config, the moment you install

Laravel package discovery wires NextPDF into the container automatically — the service provider, the Pdf Facade, and the response helpers register themselves. There is no manual provider list to edit and no config to publish before your first PDF.

Heavy documents, off the request

Dispatch GeneratePdfJob to your queue and a background worker renders the document out-of-band. You hand it a builder class and a context array; it produces the file without blocking the web request — ideal for month-end reports and batch runs.

Safe under Octane and Reverb

Singleton registries are guarded with locks and LRU caching, while every request resolves a fresh Document from the factory. Long-running Octane and Reverb workers reuse the expensive parts and never leak state between requests.

Get started

Install

terminal
composer require nextpdf/laravel

In code

How it works

Facade usage

php
use NextPDF\Laravel\Facades\Pdf;

// Facade resolves a fresh Document from the container (DocumentFactory)
Pdf::addPage();
Pdf::cell(0, 10, 'Hello from Laravel!', newLine: true);
Pdf::save('/path/to/hello.pdf');

Download response

php
use NextPDF\Contracts\PdfDocumentInterface;
use NextPDF\Laravel\Http\PdfResponse;

public function download(Invoice $invoice): \Illuminate\Http\Response
{
    $doc = app(PdfDocumentInterface::class);
    $doc->addPage();
    $doc->cell(0, 10, "Invoice #{$invoice->number}", newLine: true);

    return PdfResponse::download($doc, "invoice-{$invoice->number}.pdf");
}

Queued generation by builder class

php
use NextPDF\Laravel\Jobs\GeneratePdfJob;

GeneratePdfJob::dispatch(
    builderClass: MonthlyReportBuilder::class,
    outputPath: storage_path('reports/january-2026.pdf'),
    builderContext: ['revenue' => '$124,500'],
);

Capabilities

What you get

  • Auto-discovery — zero-config registration via Laravel package discovery
  • Pdf Facade — expressive, static-proxy API for creating documents
  • PdfResponse — download, inline, and streamed responses with OWASP headers
  • GeneratePdfJob — dispatch PDF generation to background queues
  • Extension detection — Artisan and Pro auto-configured when installed
  • Octane / Reverb safe — singleton registries with lock and LRU; Document is always fresh

When to use it

Reach for this when you are building on Laravel 12 and want PDF generation wired into the container, responses, and queues with zero manual setup. Octane- and Reverb-safe, so it fits long-running worker deployments.