dante918/livewire-pdf-preview
Livewire PDF Preview provides a reusable Livewire component for embedding and viewing PDF documents in Laravel applications. It supports configurable viewer controls, responsive sizing, and simple Blade integration, making it easy to add interactive PDF previews without building a custom viewer.
This package wraps Mozilla's pdf.js for use inside Laravel apps, so you can render PDFs client-side without shipping documents through a third-party viewer. The 1.0.2 release is a maintenance + flexibility bump: it refreshes the bundled pdf.js/pdf.worker.js to the latest upstream version, exposes a configurable worker path, and renames the install command.
Minimal setup:
php artisan list for the current command name rather than copying old docs/tutorials).pdf.worker.js is available under public/ or your asset pipeline.First use case to validate end-to-end: a single <iframe>/<canvas> viewer loading a PDF from Storage::url(...) behind your normal auth middleware. If that renders, the worker is being found and served correctly — which is the single most common failure point with this package.
Where to look first:
pdf.worker.js location in public/vendor/... after publishing.Standard config-based worker path. With 1.0.2 you can point the viewer at a custom worker URL instead of relying on the package's default. This is the pattern to adopt when:
public path.pdf.js version and want the worker to match it.Configure it once in config/...php (or env) and let the package's JS pick it up — avoid hardcoding worker URLs in Blade templates.
Auth-gated PDF streaming. Keep PDFs behind Laravel routes, not public storage. Pattern: define a route with auth/can middleware that streams via response()->file(...) or Storage::download(...), then have the viewer fetch that URL. Do not expose storage/app publicly just to satisfy the viewer.
Version pinning between API and worker. Because 1.0.2 bumps the bundled worker, treat pdf.js core and pdf.worker.js as a matched pair. If you override the worker path to a CDN copy, pin the CDN URL to the exact version the package ships — mismatched major API/worker versions produce cryptic rendering failures.
Blade integration. Wrap viewer initialization in a small dedicated JS module rather than inlining it per page; pass the PDF URL and worker path as data attributes or a config object. This keeps the upgrade path clean when the package updates pdf.js again.
Install command naming. If you have deploy scripts, Dockerfiles, or CI steps invoking the installer, audit them against 1.0.2's renamed command. This is the kind of change that silently fails deploys rather than failing tests.
grep your codebase and CI config for the old invocation before upgrading.pdf.worker.js, it's almost always a path issue, not a pdf.js bug. With 1.0.2, the new custom worker path parameter is the fix — check whether your asset pipeline (Vite, Mix, CDN) has moved the file away from the default location.pdf.js core is a nasty, hard-to-reproduce class of bug.pdf.js can include rendering differences, deprecated API removals, and changed default behaviors. Smoke-test any complex PDFs (forms, annotations, large documents) your app actually renders — don't assume a worker bump is cosmetic.php artisan config:cache will freeze it; changes to the config/env value won't take effect until re-cached. Common "my config change did nothing" trap.pdf.worker.js actually lands in public/. A composer update alone won't move the file if it's been published previously.How can I help you explore Laravel packages today?