spatie/laravel-pdf
Generate PDFs in Laravel from Blade views with a fluent API. Choose drivers like Chromium (Browsershot), Gotenberg, Cloudflare, WeasyPrint, or DOMPDF. Save to disk or return as a response, with support for modern CSS and paged media.
events system (e.g., PdfGenerated), enabling workflows like logging, analytics, or notifications post-generation.barryvdh/laravel-dompdf or spatie/laravel-snappy). Composer handles conflicts gracefully.Pdf::fake()), easing CI/CD pipelines.wkhtmltopdf), adding deployment complexity.Pdf::queue()) for async generation; monitor memory usage.spatie/laravel-pdf and engine release notes.wkhtmltopdf) in all environments (CI, staging, production)?Pdf::store()) suffice?Pdf::loadView()).PdfGenerated for post-processing (e.g., storage, analytics).Pdf::queue() with shouldQueue().Pdf::fake()) and use Laravel’s HTTP tests for end-to-end validation.spatie/laravel-pdf.composer require spatie/laravel-pdf.php artisan vendor:publish --tag="pdf-config".use Spatie\Pdf\Pdf;
Pdf::loadView('invoices.pdf', ['invoice' => $invoice])->save(storage_path('app/invoices/invoice.pdf'));
Pdf::queue() and configure shouldQueue().PdfGenerated for side effects.Pdf::store()).spatie/laravel-pdf for breaking changes (MIT license allows forks if needed).composer.json to avoid unexpected upgrades.composer why-not spatie/laravel-pdf to debug dependency conflicts.Pdf::loadView()->download() to inspect output.wkhtmltopdf is installed and accessible.queue worker memory limits.Pdf::fake() for unit tests.queue:failed table for async job errors.Pdf::queue()).memory_limit for workers.wkhtmltopdf CLI flags (e.g., --lowquality for drafts).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Engine crashes (e.g., Snappy) | PDF generation fails silently. | Fallback to DomPDF or notify users. |
| Queue worker dies | Async PDFs pile up. | Monitor queue length; implement retries. |
| Storage backend unavailable | PDFs can’t be saved/downloaded. | Use local fallback storage temporarily. |
| Template rendering errors | Corrupted PDF output. | Validate Blade templates with Pdf::fake(). |
| High concurrency | Server overload. | Rate-limit PDF endpoints; use queues. |
loadView, download, save).views/pdf/{module}.pdf).How can I help you explore Laravel packages today?