I'm using XSL-FO to generate an account statement print out. The PDF is actually just a simple table with a simple header on every page. The difficulty is that I have to display transaction volumes per page, e.g.
Page 1
+------------------------------+-----------+-----------+---------------------+
| Text | Credit | Debit | Balance |
+------------------------------+-----------+-----------+---------------------+
| Previous month | | | (*1) 1000 |
| abc | 1000 | | 2000 |
| abc | | 500 | 1500 |
| abc | | 200 | 1300 |
| ... | | | |
| Carry over | (*2) 1000 | (*3) 700 | (*4) 1300 |
+------------------------------+-----------+-----------+---------------------+
Page 2
+------------------------------+-----------+-----------+---------------------+
| Text | Credit | Debit | Balance |
+------------------------------+-----------+-----------+---------------------+
| Previous page | (*2) 1000 | (*3) 700 | (*4) 1300 |
| abc | 1000 | | 2300 |
| abc | | 500 | 1800 |
| abc | | 200 | 1600 |
| ... | | | |
| Carry over | (*2) 2000 | (*3) 1400 | (*4) 1600 |
+------------------------------+-----------+-----------+---------------------+
Here are some explanations:
- This is the previous month's balance. It's pre-calculated and well-known as an XSL variable. No problem with that, that's a regular header (only on the first page)
- This value is calculated on a per-page basis. It sums up all credit amounts on the same page. I can't calculate that myself, as I don't know when XSL-FO will do the page break. So I imagine XSL-FO must do the calculation for me. The sum at the bottom of a page is the same as the value at the top of the subsequent page.
- This value is the same as 2, only for debit amounts.
- This value is just the last transaction's balance at the bottom of a page. That value is repeated at the top of the next page.
How can I do these calculations with XSL-FO?
See also this related question: How to display one or the other information depending on the page number in XSL-FO?