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 Weasyprint Laravel Package

fruitcake/laravel-weasyprint

Laravel wrapper for WeasyPrint that converts HTML and CSS, including Blade views, into high-quality PDFs. Offers a simple API for generating, saving, and streaming PDFs directly from your Laravel application.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature delivery: server-side PDF generation from HTML/CSS — quotes, invoices, statements, tickets, compliance reports, packing slips, and any document that a designer wants to author in HTML rather than a PDF templating DSL.
  • Build vs buy: buy the wrapper, adopt the renderer deliberately. This package is thin glue around WeasyPrint, a Python HTML/CSS-to-PDF engine. The real product decision is WeasyPrint vs. a headless-browser renderer — not this package vs. hand-rolling a wrapper. Choosing it means choosing paged-media fidelity (running headers/footers, @page margins, page counters, cross-references, print-grade typography) over pixel-parity-with-Chrome.
  • Roadmap input: document-heavy features. If the roadmap contains invoicing, reporting exports, e-signature packets, or regulated statements with pagination and print layout requirements, this is a credible foundation. If PDFs are a rare, low-fidelity "export to PDF" convenience, the operational cost of a Python runtime is likely not justified.
  • Architectural decision: adding a Python sidecar to a PHP stack. Adoption is a deploy-topology decision as much as a library decision — container image, CI, and platform (Laravel Vapor, Heroku, shared hosting) must all be able to install and run WeasyPrint's native dependencies (Pango, Cairo, GDK-Pixbuf).
  • Risk tracking: pre-1.0 dependency. At v0.3.x the public API and integration surface are still stabilizing; this release is a reminder that the package is immature relative to the ecosystem's mature PDF options.

When to Consider This Package

Consider it when:

  • Output must be print-grade and paginated: page numbering ("Page 3 of 12"), repeating table headers across page breaks, footnotes, widow/orphan control, table-of-contents with resolved page numbers, or absolutely positioned running elements.
  • Templates are owned by designers or reused from a web/email design system, so HTML+CSS is the natural authoring format.
  • Documents are generated server-side in batch or on-demand, with output determinism that matters (stable pagination, reproducible renders for audits).
  • You are already comfortable operating at least one non-PHP runtime in production, or you can containerize the service.
  • Volume and latency are moderate — WeasyPrint is CPU-bound and slower than headless Chromium on complex pages; acceptable for asynchronous jobs, questionable for synchronous request paths.

Look elsewhere when:

  • You need pixel-perfect parity with a Chrome-rendered page, or templates depend on modern CSS/JS layout (flex/grid edge cases, web fonts loaded by script, client-side charting). A Browsershot/Puppeteer-style driver is the better fit.
  • Your hosting forbids native/system packages or non-PHP runtimes — Laravel Vapor, many shared hosts, and locked-down PaaS images make WeasyPrint painful.
  • You want one abstraction over multiple drivers so you can swap renderers later without touching call sites; a driver-agnostic PDF abstraction is a safer architectural bet than binding directly to one engine.
  • Your needs are simple, mostly static documents and low volume — DomPDF-style pure-PHP renderers remove an entire class of operational risk for a small fidelity trade-off.
  • You require a stable, semver-committed public API. At v0.3.x, expect churn; pin versions and wrap the package behind your own small service class so upgrades are cheap.

On v0.3.3 specifically: this is a patch release correcting a malformed facade alias in composer.json. It is not a breaking change and adds no capability, but it matters for teams relying on Laravel's package auto-discovery to resolve the WeasyPrint facade without manual alias registration — if you had worked around the alias by registering it by hand, verify the workaround doesn't double-register after upgrading. Treat it as routine maintenance: upgrade on your normal patch cadence, and let it reinforce the recommendation to pin ^0.3 and isolate usage behind an internal interface.

How to Pitch It (Stakeholders)

For executives (30 seconds): We need PDF output for [invoices/statements/reports]. Instead of building a document engine, we'd adopt a small open-source Laravel component that drives WeasyPrint, a mature HTML-to-PDF renderer. It gives us professional, print-quality documents — correct page numbering, repeating headers, clean page breaks — authored in standard HTML/CSS, so design and content teams work in tools they already know. Cost is low; the main trade-off is that it requires a Python component in our deployment, which our infrastructure can accommodate. The library is early-stage (v0.3.x), so we will pin the version and keep it behind a thin internal wrapper to protect against future changes. Latest patch release is a minor configuration fix, not a functional change — no impact on scope or timeline.

For engineering:

  • This is a wrapper, not a renderer. WeasyPrint does the work; the package provides the Laravel service provider, config, and facade. Our dependency risk splits accordingly: the wrapper may churn (pre-1.0), the renderer is stable and widely used.
  • Deployment requirement: install WeasyPrint and its native dependencies (Pango/Cairo family) in the runtime image. That means a container or a build step — verify against our actual hosting target before committing.
  • Performance profile: CPU-bound, single-process by default. Plan for queued generation for anything batch or large; don't put it on a hot synchronous request path without benchmarking our real templates.
  • Upgrade note for v0.3.3: fixes a malformed facade alias in composer.json. If any environment manually registered the alias to work around the bug, remove that workaround when bumping to avoid duplicate registration. Standard patch upgrade otherwise.
  • Recommended hygiene: pin ^0.3, wrap calls in an internal DocumentRenderer interface, and keep templates and CSS in version control alongside the code that renders them. That keeps a future swap to a browser-based renderer a contained change rather than a rewrite.
  • Exit criteria to revisit: if we hit CSS layout cases WeasyPrint can't render faithfully, or if the Python dependency becomes a deployment blocker, we switch drivers behind the same interface.
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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel