Hi There!
First of all i love the simplicity which the Anvil PDF creation offers, thus I hope to find a soltion which allows me to stay with anvil pdf’s. Any suggestions appreciated.
Usecase
I have a list of offers which can be printed. Currently there is a button in each row which lets you print the offer. This is already used in Production Version and works pretty good.
Now we want to be able to select multiple orders and print all selected Orders (lets say up to 100 Orders). Thus no loop over each because this would result in 100 printing dialouges.
I have thought about generating the pdf when the order is saved, currently this would result in too much usless PDF creation since most orders are not even printed and changed quite often before finally printed.
(Example of the UI, orders are selected and all selected orders then printed, i.e. one document)
Problems with my Attempts
I’m not able to share the application, but my current implementation looks like this:
https://anvil.works/build#clone:6FBGNTPHWXFPXMVM=VINOWOPWVQKKHTFAV5Z6UUKR
General Performance
Creating a fairly simple Order 1-3 Pages takes me 5 seconds. Including Roundtrip time this can be too long. Even in the VERY Simple example above the creation itself takes 2 seconds. (Compared with other Libraries this ist about 50 times slower)
- Do you see a way to improve my Performance in general?
1st Attempt
Creating each pdf in a loop and merging them back together with pypdf2.
This would simply take too long considering the amount it takes to create a single pdf.
2nd Attempt
Putting the original Form in a Repeating panel and populate all x orders at once and create the pdf just once. This works in principle, however I could not get a page break to work.
2. Is this the way to go? If yes, how do I handle the Page break for different Page formats (A4, A5 etc.)
Additional Question:
Could i save the last roundtrip by sending the pdf itself at 2. instead of the url?
If so, any idea on how to implement it?
- C requests a pdf
- S creates pdf and sends back url
- url is used to print/show a pdf
3rd Attempt
Would be to try other libraries like PyFPDF, ReportLab
Yet this would result in massive costs for us since the application includes dozens of different PDF Templates currently created in Anvil.
So I sincerly hope I can avoid this path(;
Thanks in advance for your help!