Forum How do I...?

How can I know which information was used on each page?

donbonifacio
We are generating an invoice. The invoice has lines with arbitrary size. Prince properly splits lines per page.

The problem is that at the end of each page, we need to print:
- The total sum of all items until that page
- The sum of the items of just that page

So we need to know what items did prince put on each page.

Any tips on how to do this?

Thanks
mikeday
This is going to require a two-pass process where you generate the PDF, then run some JavaScript that uses the box-tracking API to find out what ended up on each page and generates some data to feed back to the calling process, which runs Prince again using that data to put labels on each page.

It's a bit of work to setup, but it's the only way to get content in the document that depends on layout. There is an example here of how to do changebars, which uses a similar two-pass process.
donbonifacio
Thanks mikeday, we'll investigate that.