Skip to content

[Maintenance][DX] Add support for PDF generation abstraction#493

Open
NoResponseMate wants to merge 1 commit intoSylius:2.1from
NoResponseMate:pdf/abstraction
Open

[Maintenance][DX] Add support for PDF generation abstraction#493
NoResponseMate wants to merge 1 commit intoSylius:2.1from
NoResponseMate:pdf/abstraction

Conversation

@NoResponseMate
Copy link
Copy Markdown
Contributor

@NoResponseMate NoResponseMate commented Mar 27, 2026

Summary

This PR adds support for sylius/pdf-generation-bundle as a modern alternative to the legacy PDF generation setup based on KnpSnappyBundle with a hardcoded wkhtmltopdf binary.

The new integration is opt-in and fully backward compatible — existing setups continue to work without any changes.

Motivation

The current PDF generation in RefundPlugin is tightly coupled to KnpSnappyBundle and wkhtmltopdf. The sylius/pdf-generation-bundle provides a proper abstraction layer with support for multiple adapters, context-based configuration, and a unified filesystem management — making it easier to swap PDF engines or customize the generation pipeline.

How to use it

To switch from the legacy PDF generation to the new bundle, set the legacy option to false in your configuration:

sylius_refund:
    pdf_generator:
        legacy: false

That's it. The plugin automatically configures a sylius_refund context in sylius/pdf-generation-bundle with the knp_snappy adapter and gaufrette storage, making it a drop-in replacement.

For more details on available adapters, storage options, and custom option processors, refer to the sylius/pdf-generation-bundle documentation.

Deprecations

The following classes and interfaces are deprecated and will be removed in 3.0:

Deprecated Replacement
TwigToPdfGeneratorInterface TwigToPdfRendererInterface from sylius/pdf-generation-bundle
TwigToPdfGenerator TwigToPdfRendererInterface from sylius/pdf-generation-bundle
PdfOptionsGeneratorInterface Option processors from sylius/pdf-generation-bundle
PdfOptionsGenerator Option processors from sylius/pdf-generation-bundle
CreditMemoFileManagerInterface PdfFileManagerInterface from sylius/pdf-generation-bundle
CreditMemoFileManager PdfFileManager from sylius/pdf-generation-bundle

The corresponding services (sylius_refund.generator.twig_to_pdf, sylius_refund.generator.pdf_options, sylius_refund.manager.credit_memo_file) are also deprecated.

Issues

Fixes #329, fixes #480

@GSadee GSadee marked this pull request as ready for review April 16, 2026 09:26
@GSadee GSadee changed the base branch from 2.0 to 2.1 April 16, 2026 12:25
@GSadee GSadee added Feature New feature proposals. Maintenance Configurations, READMEs, releases, etc. DX Issues and PRs aimed at improving Developer eXperience. labels Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DX Issues and PRs aimed at improving Developer eXperience. Feature New feature proposals. Maintenance Configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants