Example with interaction between the row borders and the header and footer borders
This example explores what happens if the border of one of the rows has precedence over the header and footer borders.
<fo:table border="solid 5">
<fo:table-header border="solid 4">
<fo:table-row>
<fo:table-cell line-height="8" border="solid 1" number-columns-spanned="2">
<fo:block>HEADER</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-footer border="solid 4">
<fo:table-row>
<fo:table-cell line-height="8" border="solid 1" number-columns-spanned="2">
<fo:block>FOOTER</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-footer>
<fo:table-body border="solid 3">
<fo:table-row border="solid 6">
<fo:table-cell line-height="10" number-rows-spanned="2" border="solid 1">
<fo:block>block1</fo:block>
<fo:block>block2</fo:block>
<fo:block>block3</fo:block>
</fo:table-cell>
<fo:table-cell line-height="15" border="solid 1">
<fo:block>blockA</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell line-height="20" border="solid 1">
<fo:block>blockB</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>An sketch of this example:
no breaks | step 1 | step 2 | step 3 | step 4
| | | |
5 | 5 | 5 | 5 | 5
8 | 8 | 8 | 8 | 8
4+2 | 4+2 | 4+2 | 4+2 | 4+2
10 15 | 10 - | 10 15 | 10 15 | 10 15
10 6 | | | 10 | 10
10 20 | | | | 10
4 | 4+2 | 4+2 | 4+2 | 4
8 | 8 | 8 | 8 | 8
5 | 5 | 5 | 5 | 5
----------------------------------------------------------- page break
| 5 | 5 | 5 | 5
| 8 | 8 | 8 | 8
| 4+2 | 4 | 4 | 4
| 10 15 | 10 20 | 10 20 | - 20
| 10 6 | 10 | |
| 20 | | |
| 4 | 4 | 4 | 4
| 8 | 8 | 8 | 8
| 5 | 5 | 5 | 5
Normal borders (assuming no breaks)
Cell1 before: 6 (border-before row1 is dominant) Candidates: border-after header cell, border-after header row, border-after header body, border-before cell1, border-before row1, border-before body after: 4 (body border-before of table-footer is dominant) Cell2: before: 6 (border-before row1 is dominant) after: 6 (row border is dominant) Candidates: border after cell2, border-after row1, border before cell 3, border before row2 Cell3: before: 6 (row border is dominant) after: 4 (body border-before of table-footer is dominant)
We split the border after the header: 4 for the border-after of table-header, which is there when it does not border on the first row; this part is added to the penalties. 2 for the border-before row1; this part is added to the total height and the steps.
Table header and footer width
Header is 5 + 8 = 13, border after = 4 Footer is 8 + 5 = 13, border before = 4
Row heights
row1: 2 (extra border height) + 15 + (6/2) => (20,20,20) row2: 20 + (6/2) => (23,23,23) row group (43,43,43)
Steps
Step 1: stepw= 2 + 10 + 2 maxRemainingHeight = 43 addedBoxHeight = 0 penalty = 14 + 43 - 43 = 14 effPenalty: w = 14 (space for block1) + 13 (header) + 4 (border-after-header) + 4 (border-before-footer) + 13 (footer) box = 14 - 0 - 14 = 0 Step 2: stepw = 2 + 15 + 2 maxRemainingHeight = 20 addedBoxHeight = 0 penalty = 19 + 20 - 43 = -4 offPenalty: w = -4 (calc penalty) + 13 + 4 + 4 + 13 box = 19 - 0 - (-4) = 23 Step 3: stepw = 2 + 10 + 10 + 2 = 24 maxRemainingHeight = 20 addedBoxHeight = 23 penalty = 24 + 20 - 43 = 1 effPenalty: w = 1 (calc penalty) + 13 + 4 + 4 + 13 box = 24 - 23 - 1 = 0 Step 4: stepw = 2 + 10 + 10 + 10 = 32 maxRemainingHeight = 20 addedBoxHeight = 23 penalty = 32 + 20 - 43 = 9 effPenalty: w = 9 (calc penalty) + 13 + 4 + 4 + 13 box = 32 - 23 - 9 = 0 Step 5: stepw = 2 + 15 + 6 + 20 = 43 maxRemainingHeight = 0 addedBoxHeight = 23 penalty = 43 + 0 - 43 = 0 (last step, omit penalty) box = 43 - 23 - 0 = 20
End result (with raw penalties)
box(0)
penalty(14) -> 14/43
box(23)
penalty(-4) -> 19/20
box(0)
penalty(1) -> 24/20
box(0)
penalty(9) -> 32/20
box(20)
-> 43
End result (effective)
box(0)
penalty(48) //incl. header and footer -> 48/77
box(23)
penalty(30) //incl. header and footer -> 53/54
box(0)
penalty(35) //incl. header and footer -> 58/54
box(0)
penalty(43) //incl. header and footer -> 66/54
box(20)
box(17) //header
box(17) //footer
-> 77