bithost-gmbh / pdfviewhelpers

TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.
GNU General Public License v3.0
44 stars 19 forks source link

Shouldn't/couldn't an image (in general and) in the header be embedded in a PDF as a reference - to save memory? #225

Open thorstenBorn-cosmoblonde opened 1 year ago

thorstenBorn-cosmoblonde commented 1 year ago

Hello! We have noticed that images (logos, for example) that are included in headlines (with pdf:header) are not available as a reference in the generated PDF, but are included directly. PDF could do this differently, right(?), but I wonder whether this is a bug in pdf-Viewhelper or already the case in the Fpdi class library - that's why this is not a bug report or a feature request yet.

In case it is not possible to correct it at the moment (because Fpdi is the reason), a note in the documentation would be helpful: The number of pages and the size of images can quickly result in large files. We just have cases of 15-page PDFs with a 200kB image (SVG) in the header and that means that the 200kB become 3MB just by calculation (and that does not include the conversion of the SVG into PDF "code"). In PDF there are probably even more (some files are larger than 6 MB).

@maechler: btw - Thank you for taking ticket #208 seriously and that it is already being implemented.

maechler commented 1 year ago

@thorstenBorn-cosmoblonde That's a very good question, I actually don't know. We are using TCPDF to generate the PDF. I had a very quick look at the API, but did not yet find something. If you have time to look a bit deeper into this topic that would be great. If there is an easy way to support that, then I would be happy to add it.

To import existing PDF documents as a template we are using FPDI, could be that they implement something like this. If you want to, you could give it a try using a template PDF instead of a regular header: https://docs.typo3.org/p/bithost-gmbh/pdfviewhelpers/main/en-us/Examples/ExtendExistingPDFs/Index.html

thorstenBorn-cosmoblonde commented 1 year ago

Thanks @maechler for your quick response. Asking me for time ;-)... after the holidays I will try to get more into it. Thanks for the template hint. It's easier for editors in our project to upload a logo than to create a PDF containing the logo - I guess. But with this solution you can at least decide.

I strongly suspect that it is a bug in TCPDF. When I know more, I'll get back to you.