Start here Conceptual overview · 4 min read

Introduction

BladePDF turns Blade-friendly HTML into production PDFs from your Laravel application. It supports local Laravel views, raw HTML strings, and cloud Blade templates managed in the dashboard.

Render sources
fromView() renders a local Laravel view first
fromHtml() sends raw HTML directly
fromTemplate() renders a cloud Blade template with JSON context

What BladePDF does

BladePDF gives your application a fluent API for rendering PDFs and a dashboard for managing templates, assets, render history, and webhooks.

Choose where the document content comes from, pass the data needed to render it, configure the PDF options, and decide how the result should be returned or stored.

Laravel package

Use the BladePDF:: facade in routes, controllers, queued jobs, or services.

Cloud templates

Publish templates and assets from the dashboard, then render them by id.

PDF options

Control paper size, margins, orientation, backgrounds, page ranges, and waiting behavior.

Render history

Review status, timings, logs, asset metrics, and webhook deliveries from the dashboard.

Choose a source

Method Best for Where Blade runs
BladePDF::fromView() Existing Laravel views, invoices, labels, internal reports Your Laravel app
BladePDF::fromHtml() Already-rendered HTML strings, generated snippets, tests Nowhere; HTML is already final
BladePDF::fromTemplate() Cloud-managed templates that developers can publish in the dashboard BladePDF

One render contract

Once you choose a source, the rest of the API stays the same. You can set metadata, PDF options, request-scoped asset overrides, persistence, and then call render() or async().

Three source types
php
 1BladePDF::fromView('pdf.invoice', ['invoice' => $invoice]);
 2
 3BladePDF::fromHtml($html);
 4
 5BladePDF::fromTemplate('invoice.standard', [
 6    'invoice' => $invoice->toArray(),
 7]);

All three can continue with the same document options:

Shared options
php
 1return BladePDF::fromTemplate('invoice.standard', $context)
 2    ->reference($invoice->uuid)
 3    ->format('A4')
 4    ->margins(top: '16mm', right: '12mm', bottom: '18mm', left: '12mm')
 5    ->showBackground()
 6    ->storePdf()
 7    ->render()
 8    ->download("invoice-{$invoice->number}.pdf");

Basic example

The public Laravel API is intentionally small: pick the source, set metadata/options, then call render() and use the returned result.

routes/web.php
php
 1use BladePDF\Laravel\Facades\BladePDF;
 2
 3Route::get('/invoices/{invoice}/pdf', function (Invoice $invoice) {
 4    return BladePDF::fromView('pdf.invoice', [
 5        'invoice' => $invoice,
 6    ])
 7        ->reference($invoice->uuid)
 8        ->format('A4')
 9        ->showBackground()
10        ->render()
11        ->download("invoice-{$invoice->number}.pdf");
12});

Cloud templates

Cloud templates let you update document markup from the dashboard without deploying your Laravel app. Your application sends the template id and a JSON object used as context.

Cloud template render
php
 1return BladePDF::fromTemplate('invoice.standard', [
 2    'invoice' => $invoice->toArray(),
 3    'customer' => $invoice->customer->toArray(),
 4])
 5    ->reference($invoice->uuid)
 6    ->storePdf()
 7    ->render()
 8    ->response('invoice.pdf');

What happens after a request

The request is authenticated and validated.
BladePDF prepares the HTML and resolves any referenced assets.
The PDF is generated with your selected options.
The result is returned, downloaded, saved locally, or persisted with storePdf().
Render details and webhook deliveries are recorded in the dashboard.

Core concepts

Concept Use it for
context Structured data passed to fromTemplate() and used by the cloud Blade template.
metadata User-facing render labels such as reference and, for HTML/view renders, template_name.
asset:///... Assets stored in the dashboard, with optional request-level overrides.
storePdf() Persist the generated PDF in BladePDF while still returning it to your app.

Next steps

Was this page helpful?
Let us know if something's missing or unclear.