Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Snappy

Laravel Snappy Laravel Package

barryvdh/laravel-snappy

Laravel wrapper for Snappy that generates PDFs and images from HTML using wkhtmltopdf and wkhtmltoimage. Render Blade views or raw markup and configure page size, orientation, headers, footers, and custom binary options through a simple, familiar Laravel API.

View on GitHub
Deep Wiki
Context7

barryvdh/laravel-snappy is a Laravel wrapper for the Snappy library, letting you convert HTML into PDF or images using the wkhtmltopdf and wkhtmltoimage binaries. It integrates cleanly with Laravel, exposing configurable services, facades, and Blade-rendered views for generating documents.

  • Generate PDFs and images from HTML or Blade views
  • Configurable binary paths and global options
  • Fluent interface for per-document settings
  • Support for headers, footers, and page options
  • Simple facade and service container integration
Frequently asked questions about Laravel Snappy
How do I install barryvdh/laravel-snappy in a Laravel app?
Install the package with Composer using composer require barryvdh/laravel-snappy. Laravel auto-discovers the service provider and facade, then you publish the config file with vendor:publish and set the wkhtmltopdf and wkhtmltoimage binary paths. Make sure the binaries are installed and executable in every environment before generating documents.
Does laravel-snappy support Laravel 11, 12, and 13?
Yes, recent releases track Laravel versions: v1.0.3 targets Laravel 11, v1.0.4 targets Laravel 12, and v1.0.5 targets Laravel 13. Check the Composer constraint for your Laravel version before upgrading. Release cadence is compatibility-only, so do not expect new rendering features from the wrapper.
How do I configure the wkhtmltopdf binary path in Laravel Snappy?
Publish config/snappy.php and set the binary paths in the pdf and image sections, for example binary => /usr/local/bin/wkhtmltopdf. You can also pass per-generation options such as page size and margins through the loadView call. Keep paths consistent across local, CI, staging, and production so output does not change between environments.
Can I generate a PDF from a Blade view with laravel-snappy?
Yes, use PDF::loadView('invoices.pdf', $data)->download('invoice.pdf') to render an existing Blade template as a PDF. You can also use loadHTML for raw markup when a view is not needed. Reusing Blade views avoids duplicating design and copy between the web page and the PDF.
How do I save or stream PDF output instead of downloading it?
Call download() to send the PDF as an attachment or inline() to display it in the browser; both return a Laravel response. To store the file, call save($path), which writes through Laravel's filesystem abstraction. For large documents, generate in a queued job, save to storage, and serve the file with a signed URL.
Does laravel-snappy work on Laravel Vapor or serverless platforms?
No, Laravel Vapor and similar FaaS runtimes cannot host arbitrary binaries like wkhtmltopdf. Use a container-based platform where you can install and pin the binary version, or choose a hosted rendering API instead. Confirm the target runtime before committing to a delivery date.
What are the limitations of wkhtmltopdf for modern CSS and webfonts?
wkhtmltopdf uses an ageing Qt/WebKit engine, so Flexbox, CSS Grid, position: fixed, webfonts, and JavaScript-driven content may not render reliably. Validate your real designs early, because late rework on templates is the main scope risk. For complex layouts or pixel-perfect fidelity, consider headless Chrome or a hosted rendering API.
Is laravel-snappy safe to use with user-supplied HTML?
Treat any path where user-supplied HTML or remote URLs reach the renderer as a code-execution vector. Restrict input to your own Blade templates and sanitize or escape any user-contributed fragments. Do not allow arbitrary URLs or local file access, and make this a non-negotiable acceptance criterion.
How do I generate PDFs asynchronously with queues in Laravel?
Dispatch a queued job that calls PDF::loadView(...)->save($path) and stores the result through Laravel's filesystem. The package integrates with the queue worker, so slow templates do not block HTTP requests. For high volume, generate async-only from day one and serve completed documents with signed URLs.
What are alternatives to barryvdh/laravel-snappy for PDF generation in Laravel?
Alternatives include Dompdf for simple templates, hosted rendering APIs for higher fidelity, and headless Chrome tools such as Browsershot. Choose based on CSS requirements, binary hosting constraints, and peak volume. Because laravel-snappy is a thin wrapper, you can isolate rendering behind an interface to make switching engines easier later.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource