Skip to content

Add Weasyprint driver - #304

Merged
freekmurze merged 6 commits into
spatie:mainfrom
barryvdh:weasyprint
Feb 12, 2026
Merged

freekmurze merged 6 commits into
spatie:mainfrom
barryvdh:weasyprint

Conversation

@barryvdh

Copy link
Copy Markdown
Contributor

Not sure what the best way for custom drivers should be. I first created it as a driver in fruitcake/laravel-weasyprint: fruitcake/laravel-weasyprint#11

That would make it easier to maintain I guess, without specifying explicit version numbers.

Functionally it would be the same:
A. Require fruitcake/laravel-weasyprint, set config in config/weasyprint.php -> Can now also use the weasyprint driver.
B. Require the pontedilana/php-weasyprint and use the config from config/laravel-pdf -> Can now also use the driver.

I guess it kinda depends on what you want to do with custom drivers. Maybe you could link to 3rd party drivers?

@freekmurze

Copy link
Copy Markdown
Member

Since I don't think having the driver inside of the package will be a big maintenance burden. I can image the code won't change much over time.

Let me know when it's ready for review 👍

Thanks for working on this!

@barryvdh
barryvdh marked this pull request as ready for review February 11, 2026 12:44
@barryvdh

Copy link
Copy Markdown
Contributor Author

It's ready but not sure how to add test. I guess it would make sense to use dependency injection instead of the new class, and mock that. But I stuck with how Dompdf was done (and have the check for the package)

I can change it to use the container if you want

@freekmurze

Copy link
Copy Markdown
Member

Thanks Barry, this looks great! A few small things:

  1. Typo in the config: "secods" → "seconds"
  2. buildWeasyPrint() is public while the equivalent buildDompdf() is protected — could you make it protected for consistency?
  3. For testing: keeping it consistent with how DomPdf does it is fine by me. We can always refactor both to use DI later if needed.

Other than that, this looks ready to merge. Thanks for contributing this!

@barryvdh

Copy link
Copy Markdown
Contributor Author

Thanks Barry, this looks great! A few small things:

  1. Typo in the config: "secods" → "seconds"
  2. buildWeasyPrint() is public while the equivalent buildDompdf() is protected — could you make it protected for consistency?
  3. For testing: keeping it consistent with how DomPdf does it is fine by me. We can always refactor both to use DI later if needed.

Other than that, this looks ready to merge. Thanks for contributing this!

Done, done and done.

I think the tests should pass, but always tricky with binaries on github. Can you approve the workflows?

@freekmurze
freekmurze merged commit 367421f into spatie:main Feb 12, 2026
34 checks passed
@freekmurze

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants