Skip to content

Conversation

@StevenRenaux
Copy link

@StevenRenaux StevenRenaux commented Jul 30, 2025

Related to #376

A simple implementation for GotenbergBundle, potentially replacing wkhtmltopdf.

While integration with GotenbergBundle is possible and desirable, further testing and implementation will be required for a smooth transition of all current use cases.

Rendering by GotenbergBundle
image

@StevenRenaux StevenRenaux changed the title Generate Invoice with Gotenberg Proposal to generate an invoice with Gotenberg Jul 30, 2025
<tr>
<td>
<img width="160" src="{{ logoPath }}">
<img width="160" src="{{ generateWithGotenberg ? gotenberg_asset(logoPath) : logoPath }}">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inject the config key $config['pdf_generator']['generate_with_gotenberg'] to wrap this logic in an if maybe ?

"php": "^8.2",
"knplabs/knp-snappy-bundle": "^1.10",
"ramsey/uuid": "^4.7",
"sensiolabs/gotenberg-bundle": "^1.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest / require-dev ?

@Rafikooo Rafikooo linked an issue Oct 14, 2025 that may be closed by this pull request

if ($config['pdf_generator']['generate_with_gotenberg'] === true) {
$definition = new Definition(TwigToGotenbergPdfGenerator::class);
$definition->addArgument(new Reference('sensiolabs_gotenberg'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if the bundle is installed and throw an exception if necessary.
IMO the bundle should be optional.

if ($config['pdf_generator']['generate_with_gotenberg'] === true) {
$definition = new Definition(TwigToGotenbergPdfGenerator::class);
$definition->addArgument(new Reference('sensiolabs_gotenberg'));
$definition->setDecoratedService('sylius_invoicing.generator.twig_to_pdf');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is decoration needed since we just replace the service?

->children()
->booleanNode('enabled')->defaultTrue()
->end()
->booleanNode('generate_with_gotenberg')->defaultFalse()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a service property to set the PDF generator to use? It could be Wkhtmltopdf by default to avoid BC break and Gotenberg if the bundle is installed.

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.

Move away from wkhtmltopdf for pdf generation

3 participants