statikbe/laravel-puppeteer-pdf-converter
A Laravel package that converts Blade views or HTML into PDFs using Puppeteer and headless Chrome. It provides a simple API for generating PDFs from templates or URLs, with configurable options for page size, margins, headers, and more.
composer require statikbe/laravel-puppeteer-pdf-converter, then publish the config (php artisan vendor:publish --tag=... — check the README for the exact tag) and review config/puppeteer-pdf-converter.php.node/npm on the PATH of the web and queue users, and a Chromium binary Puppeteer can find. If the package does not auto-install its Node dependencies, run npm install inside the package directory under vendor/ and confirm the script path in config points at it.loadView() / loadHTML() → save() / download() / inline() chain.download() or save() to a Storage disk. Render one real document with images and a page break before wiring it into anything else — that surfaces the Chromium, font, and asset-URL problems immediately.InvoicePdf) that takes a model and returns a converter instance or a stored path. Controllers and jobs then stay one line, and you have a single place to change paper size, headers, or the template.GenerateInvoicePdf jobs, store the file on a disk, and serve it via a signed route or a download controller. This also keeps request timeouts out of the picture.loadView with Blade + asset()/url() helpers when the document can be fetched over HTTP by the headless browser. Mixing them — relative asset paths in a string render — is the most common source of unstyled PDFs.@page { size: A4; margin: ... }, page-break-inside: avoid on line-item rows, and thead repetition for long tables. printBackground: true is usually needed or background colours silently vanish.pageNumber/totalPages placeholders. Keep them tiny and self-contained; external CSS in a header template is unreliable.%PDF- and is non-trivial in size.npm install / clear any cached node_modules under vendor/, otherwise you keep executing the old broken script and wonder why nothing changed.--no-sandbox (and usually --disable-dev-shm-usage). Pass these through the configured Chromium args; do it in config, not in application code.@font-face or install fonts in the image; otherwise text renders in a fallback and layouts shift between local and production.about:blank. Either prefix with config('app.url')/asset() or embed as data URIs.vendor/ — subclass or wrap the converter and keep customisation on the PHP side.How can I help you explore Laravel packages today?