Laravel PDFs without Chrome or Node on your server
Tested: Laravel 13.40 on PHP 8.4, barryvdh/laravel-dompdf 3.1.2 with dompdf 3.1.6, and the PagedPDF API running locally, 2026-11-04
Most Laravel PDF packages need something installed next to PHP:
| Package | Renders with | Needs on your server |
|---|---|---|
barryvdh/laravel-dompdf |
dompdf, written in PHP | Nothing extra |
spatie/browsershot, and spatie/laravel-pdf by default |
Chrome, through Puppeteer | Node 22 or later, Puppeteer 23 or later, Chrome and Chrome's system libraries |
barryvdh/laravel-snappy |
wkhtmltopdf | The wkhtmltopdf binary, archived since 2023 |
spatie/laravel-pdf with its Gotenberg driver |
Chromium inside Gotenberg | A Gotenberg service in Docker |
spatie/laravel-pdf with its Cloudflare driver |
Cloudflare's hosted browser | A Cloudflare account, and nothing on the server |
| An HTML-to-PDF API | Chrome on someone else's server | Nothing: it's an HTTP call |
The requirements are from Spatie's docs, checked November 2026. For Forge, Browsershot's docs also list extra system packages to install. On Ubuntu 23.10 and later, they describe a kernel setting to change if Chrome fails with "No usable sandbox".
If you can't or don't want to install those, there are two choices: dompdf, or an HTTP call.
See the HTTP option on a real PDF, with nothing to install on your server: make the long invoice in the try-it box.
dompdf: nothing to install, but check your template
dompdf is the only option written in pure PHP. We printed the test document from our wkhtmltopdf comparison with barryvdh/laravel-dompdf:
| dompdf 3.1.6 | |
|---|---|
| Flexbox | Stacked vertically |
| CSS grid | Stacked vertically |
| CSS variable colour | Worked |
| Background colours | Printed |
| Scripts | Don't run |
@media print rules |
Ignored, because default_media_type in config/dompdf.php is screen |
| Table header on every page | Yes |
Rows with page-break-inside: avoid |
Kept whole |
Two more things caught us out:
- Characters outside Western European languages. With
font-family: sans-serif, dompdf used Helvetica and printed?for emoji, Japanese and even Cyrillic. Its bundled DejaVu Sans (font-family: "DejaVu Sans") fixed Cyrillic, but Japanese and emoji became empty boxes. - Images from URLs. An image from an
https://address printed as a crossed-out box, becauseenable_remoteinconfig/dompdf.phpisfalseby default. Adata:URI or a local path such aspublic_path('logo.png')worked with the default settings. Or turn remote loading on, if you trust every URL your templates contain.
dompdf is a good fit for documents built from blocks and tables, in the languages DejaVu Sans covers. Layouts built with flexbox or grid need rewriting for it.
The HTTP option
Render your Blade view to HTML, POST it to the API and return the PDF. There's nothing to install. We tested this code against the PagedPDF API running locally.
// config/services.php
'pagedpdf' => [
'key' => env('PAGEDPDF_KEY'),
'url' => env('PAGEDPDF_URL', 'https://api.pagedpdf.com/v1/pdf'),
],
// app/Http/Controllers/InvoicePdfController.php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class InvoicePdfController extends Controller
{
public function __invoke(string $id)
{
$html = view('invoice', ['id' => $id])->render(); // pass whatever your view needs
$response = Http::withToken(config('services.pagedpdf.key'))
->timeout(90)
->post(config('services.pagedpdf.url'), [
'html' => $html,
'footer' => 'Invoice '.$id.', page {page} of {pages}',
])
->throw();
if ($warnings = json_decode($response->header('X-PagedPDF-Warnings') ?: '[]', true)) {
Log::warning('Invoice PDF printed with something missing', $warnings);
}
return response($response->body(), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="invoice-'.$id.'.pdf"',
]);
}
}
// routes/web.php
Route::get('/invoices/{id}/pdf', \App\Http\Controllers\InvoicePdfController::class);
Put PAGEDPDF_KEY=your_key in .env. The footer string uses single quotes, so PHP leaves {page} and {pages} for the API to fill in.
With a 40-line invoice table in the view, the PDF came back with 2 pages, the table header repeated on page 2, and "Invoice 1042, page 1 of 2" and "page 2 of 2" in the footers.
Images and CSS: don't rely on asset()
asset() builds URLs on your app's own address. On a development machine, that's your own computer, which an outside service can't reach. Our logo didn't load. The API reported it in the X-PagedPDF-Warnings header, and the controller logged it:
local.WARNING: Invoice PDF printed with something missing [{"code":"load_failed","url":"http://127.0.0.1:8791/logo.png","message":"The image failed to load (HTTP 403)."}]
Put your CSS in a <style> block in the view, and embed small images as data: URIs:
<img src="data:image/png;base64,{{ base64_encode(file_get_contents(public_path('logo.png'))) }}" width="120">
That logo printed with no warnings. In production, asset() URLs work too if your site is public.
When nothing is wrong, the warnings header is an empty list, [], not missing. That's why the controller decodes it before checking. Checking the raw header would log a warning for every PDF.
Errors
->throw() turns a failed request into an Illuminate\Http\Client\RequestException. With a wrong key we got status 401, and $e->response->json('error.code') was unauthorized. The API docs list every error code.
Saving instead of returning
To attach the PDF to an email or keep a copy, store the body:
Storage::put("invoices/{$id}.pdf", $response->body());
Testing it
Http::fake() keeps your tests offline:
public function test_it_returns_the_pdf_from_the_api(): void
{
Http::fake([
'api.pagedpdf.com/*' => Http::response('%PDF-1.7 test', 200, ['Content-Type' => 'application/pdf']),
]);
$this->get('/invoices/1042/pdf')
->assertOk()
->assertHeader('Content-Type', 'application/pdf');
Http::assertSent(fn ($request) => str_contains($request['html'], 'Invoice 1042'));
}