Edit: I converted this topic to a feature request. I am requesting a way to shrink images so that I can make PDFs including images using HTML templating that are not 40-200 MB. The images are sent through the Fibery view from people’s phones. A function to shrink PDFs could also do the job. Or that the Fibery system automatically can make shrunken images when uploaded.
I am generating reports for a client based on form input, which includes a bunch of images. I use a button to generate it, using an HTML template. However, when I press the button it generates really big (80+ MB) PDFs of 2 pages, even though the images are small (on the pdf) it maintains the original image size.
I have tried many ways to try to shrink the PDF using JavaScript, but couldn’t get the job done. Is there any trick to get this done? I would really love to deliver to my client but this surprise + a bunch of other (smaller ones) make it kind of hard.
You really only have 3 places you can attack this. Pre-processing, PDF Generation, and Post Processing.
Pre processing - you would need to limit the file size that the form allows to upload. Currently not possible in Fibery Forms, to my knowledge. Or take the images after they have been uploaded and compress them. You theoretically could do this this with a script that runs prior to HTML PDF generation. And this is probably your best chance with Fibery capabilities.
PDF Generation - There are some JS libraries that compress images. I don’t think you will be able to call these libraries during the HTML generation, however.
Post Processing - You can always take a PDF file and compress it after the fact. So even with a large PDF initially, you can make it smaller.
Thanks! That is a well-structured answer! I explored option 2 and came to the same conclusion. And 1 I also came to the same conclusion. I just wanted to try option 3, a few minutes ago I got the idea that I can create a script that does this perhaps in Fibery… shrinking PDFs… otherwise I will do it with an external program temporarily so my client can meet his deadline
Edit: this doesn’t work because you can’t edit binaries within the Fibery JavaScript environment but I will look into other ways
I have turned this topic in a feature request. It is the main showstopper for me. My client now uses an external program to shrink the PDFs by hands after generating. I’d love to be able to make this work more elegantly. Just a function in JavaScript that can reduce the image size would already do the job, but as I have outlined in the edited OP there are multiple roads to Rome.
I will not often really ask for a feature like this but finding this one is missing is pretty painful and makes me want to escape the Fibery JS sandbox (a sandbox of course has limitations but it can still be fun to play in sandboxes as we all remember, the toys just need to be upgraded) - I know you want to do a rework of Automations but I just want to ask if this bit can be made early if it is a small thing. If it is a big change or there’s other important work with higher prio, then it’s also fine to know then I will go the n8n route for now (but then I am still curious how the rework of Automations will develop as it’s the simplest to do things like this within Fibery - and I will sit down and write a proper message to that thread soon to give some input).
Another of such “roads to Rome” is to add a little menu to the Fibery PDF generator to convert the PDF to a certain quality. That way a 200 MB pdf can be shrunk back to 200 KB (which still looks good) afterwards.
I was wresting with the Fibery PDF template to see if I can shrink the images anyways (who knows I may beat it somehow)… then the Fibery AI told me this!
I am getting close to a solution because of some puzzling from my side and most importantly help from @RonMakesSystems }
I will share the solution here for your benefit, so you don’t have to invent this wheel. It will use an external service to shrink the images.
The request still stands, it would be great if Fibery could provide thumbnails in some way. I see that the gallery view and image preview use some kind of thumbnail, could this functionality or this thumbnail file(s) be made accessible via scripting as well?
PDF export is there but I understand you look for a Button where you can do it without a script. I can help you to do it with scripting (and explain how it works it is doable!), we would already meet some time to talk about the Google Maps Timeline.
I am looking at Gallery View (for the first time) - it’s really cool! Useful for me and I am sure also for my clients
I see that there are actual thumbnails - images that are smaller in size! Behind the urls of these images I see “?width=320&height=0&dpr=2”
Tried to get something like this working in my PDF template but it doesn’t work. Am I doing something wrong or are these shrunken images not accessible from the PDF template?