sensiolabs / GotenbergBundle

A Symfony Bundle for interacting with Gotenberg. Integrates natively with twig, router, PHPStorm and more !
MIT License
35 stars 10 forks source link

Feature: Add a builder to write pdf metadata #93

Open ConstantBqt opened 4 months ago

ConstantBqt commented 4 months ago

Add WriteMetadataPdfBuilder, inspired by MergePdfBuilder

Partially resolve issue #43

ConstantBqt commented 3 months ago

I wonder though if it is worth the effort these routes ? Because we already provide a way to set metadata on generate. It requires to put the whole PDF into memory, send it though http to gotenberg and download it again as a stream response potentially. Might not be worth it. @Jean-Beru : WDYT ?

IMO this is useful to update the metadata an existing PDF file. I imagine this scenario:

Someone needs to modify thousands of its company's PDFs to change the metadata Copyright or Keywords.

Neirda24 commented 3 months ago

Someone needs to modify thousands of its company's PDFs to change the metadata Copyright or Keywords.

But then I would recommend to directly use a binary for this scenario. It requires too much memory + http bandwidth for such small and edge cases...

Jean-Beru commented 3 months ago

I wonder though if it is worth the effort these routes ? Because we already provide a way to set metadata on generate. It requires to put the whole PDF into memory, send it though http to gotenberg and download it again as a stream response potentially. Might not be worth it. @Jean-Beru : WDYT ?

Putting whole PDF in memory is not mandatory. HttpClient accepts callback and resources as body: https://symfony.com/doc/current/http_client.html#uploading-data.

But then I would recommend to directly use a binary for this scenario. It requires too much memory + http bandwidth for such small and edge cases...

Of course but some applications may want to delegate this task to the Gotenberg container.

IMHO (here @ConstantBqt :trollface: ), this endpoint can be implemented as a very simple builder. The hardest thing is to know how split our code between file generation (screenshot, pdf, etc.) and data retrieval (read metadata, async, etc.)

Neirda24 commented 3 months ago

Our implementation of the http client does not yet covers memory efficient input. even with https://github.com/sensiolabs/GotenbergBundle/pull/90 we will only cover the output part.

Jean-Beru commented 3 months ago

Our implementation of the http client does not yet covers memory efficient input. even with #90 we will only cover the output part.

Sure! It deserve a new issue to improve content and asset files.