Keep Blade logic local
Continue using loops, conditionals, translations, helpers, model data, and application services before the render leaves your app.
Use your existing Blade templates, Laravel data, CSS, images, and fonts. BladePDF moves the browser and asset-delivery work out of the application runtime.
return BladePDF::fromView('pdf.invoice', [
'invoice' => $invoice,
'company' => $company,
])
->withFooter('pdf.partials.footer')
->showBackground()
->render()
->download('invoice.pdf');
A Blade view can reference private logos, generated charts, compiled stylesheets, font files, and storage-backed images that work perfectly inside the Laravel application. A separate browser process or remote renderer cannot automatically access those local files.
BladePDF renders the view inside Laravel, discovers the referenced assets in the resulting HTML and CSS, attaches them to the render request, and rewrites their URLs before Chromium loads the document.
Continue using loops, conditionals, translations, helpers, model data, and application services before the render leaves your app.
Use normal local asset references without publishing logos, fonts, or tenant files to an open bucket.
Modern CSS, print styles, backgrounds, custom fonts, and JavaScript on eligible plans render through Chromium.
The view stays in resources/views. The controller sends its rendered output and automatically resolved assets to BladePDF.
composer require bladepdf/laravel
<link rel="stylesheet" href="{{ asset('css/invoice.css') }}">
<header>
<img src="{{ asset('images/logo.svg') }}" alt="Acme">
<h1>Invoice {{ $invoice->number }}</h1>
</header>
@foreach ($invoice->items as $item)
<div class="line-item">
<span>{{ $item->description }}</span>
<strong>{{ $item->formattedAmount() }}</strong>
</div>
@endforeach
return BladePDF::fromView('pdf.invoice', [
'invoice' => $invoice->load('items'),
])
->templateName('Invoice')
->reference($invoice->uuid)
->format('A4')
->showBackground()
->render()
->download("invoice-{$invoice->number}.pdf");
BladePDF::fromView('pdf.report', $data)
->withHeader('pdf.partials.header', $data)
->withFooter('pdf.partials.footer', $data)
->margins(18, 12, 18, 12, 'mm')
->render()
->response('report.pdf');
showBackground() when color blocks, background images, and print backgrounds are part of the design. Headers and footers are separate Chromium page chrome and have their own layout constraints.
The HTML is only useful when its styles, images, fonts, and nested references are available to the renderer.
A local browser may load application URLs, file paths, embedded data, or mounted assets, but your team owns the environment and its security boundary.
The Laravel package converts local files into request-scoped assets so the managed browser can render the same visual document without public URLs.
srcset
url() and @import references
asset:/// references
The conversion happens after Blade has produced HTML and before the managed browser opens the document.
Laravel compiles Blade with your data. fromView() receives a normal view name and data array, just like the rest of your application.
Public paths, local application hosts, filesystem paths, responsive images, stylesheets, fonts, and nested CSS dependencies are resolved.
The managed browser receives portable HTML and request assets, waits for configured readiness, and produces the PDF using your page options.
The automatic pipeline handles common local references. You can disable it or attach assets manually when a document needs explicit control.
| Capability | In the Blade view | BladePDF behavior |
|---|---|---|
| Local image | {{ asset('images/logo.png') }} |
Resolved from the Laravel public path, uploaded, and rewritten |
| Compiled stylesheet | {{ asset('build/assets/invoice.css') }} |
Attached; nested fonts and background images are scanned |
| Storage image | {{ url('storage/qrcodes/42.png') }} |
Treated as local when the host matches configured local hosts |
| Inline CSS URL | style="background:url(...)" |
Local URL is resolved and rewritten |
| Remote URL | https://cdn.example.com/chart.png |
Preserved; network access depends on the plan and request controls |
| Explicit asset | asset:///tenant-logo.png |
Attach with withAsset() or override a cloud asset for one render |
Automatic resolution can be disabled globally or per render. Manual withAsset() and overrideAsset() attachments still work when scanning is disabled.
fromView() renders the selected local view inside Laravel with the data you pass, then sends the resulting HTML and resolved assets to BladePDF.Start with one invoice, report, or certificate and keep the rest of the application flow unchanged.