Forum How do I...?

Is a carry sum possible?

FMA
Hi,

I have a large table which gets split on multiple pages.
I want to display on the last row for any page a sum of the items that are on that page.

Is this possible?

I can log the correct sum but only with the completed event (with trackBoxes) and therefore I can't manipulate the dom anymore and insert the sum.
mikeday
Right, currently this requires running Prince twice, and modifying the document based on the logged sum.

It's an awkward process, but it's the best we can do right now. Hopefully in the future we can do better.
FMA
Thanks for the quick response!

I will implement the outlined approach.

I guess this would only be possible in one run if prince gave a lot more power to inline JavaScript.
If there was a preflight event where the princeBoxes get filled with their data, one could use that to change the dom with the information. But then the JavaScript code itself would have to trigger a new preflight to see if the injected information changed anything and only if it didn't somehow trigger the final conversion to pdf.

mikeday
Yes, the ability for JavaScript to trigger reflow! Very powerful, but very scary to implement. One day. :)