## Expectations

### Simple case

Assume the page-master has the same available BPD and IPD (*) (or even a bigger available BPD). In this case, there are no special precautions when switching from a normal page-master to the page-master for the last page as the break decisions remain the same.

(*) Note: If the available IPD changes between pages we're talking about another problem: PageLayout/InfluenceOfPageSizesOnAlgorithm

```+-----+ +-----+ +-----+
| xxx | | xxx | | xxx |
| xxx | | xxx | | xxx |
| xxx | |     | |     |
| xxx | |     | +-----+
| xxx | |     | |YYYYY|
+-----+ +-----+ +-----+
1       2  -->  2*```

### Less available BPD on the last page

Here's where it gets more complicated. Here's an example: In Switzerland, we have "Einzahlungsscheine" (some kind of payment instruction form) which is often placed at the bottom of the last page of an invoice after a perforation. This eats away at the available BPD of that last page.

Now, if the page breaker initially only operates on normal non-last pages the last page may end up using more space than is available if you switch to the actual page-master for the last page. Instead of replacing the last page-master we'd have to append a new page using the "last" page-master. In the case where the content for the last page fits on the next-to-last page that last page's region-body will be empty.

```+-----+ +-----+ +-----+
| xxx | | xxx | |     |
| xxx | | xxx | |     |
| xxx | | xxx | |     |
| xxx | | xxx | +-----+
| xxx | |     | |YYYYY|
+-----+ +-----+ +-----+
1       2       3```

That's one possible expectation. It could also be expected that the last page contain at least some content. However, nobody has to date come up with a detailed description about what would be done in this case.

A problem surfacing with the first expectation is the "page x of y" problem: The usual empty block with an "EOF"-ID at the end of all content in the fo:flow ends up on the next-to-last page which causes the last page to display "page n of n-1". Either the breaker has to detect such an element and force it on the last page or a different approach has to be taken to place the "EOF" marker, i.e. implementing page-number-citation-last from XSL 1.1.

### Exotic constellations

We could come up with a somewhat exotic example where the last page has twice the available BPD than all the other pages. In that case, the content of the last two pages might fit in the region-body area of the page-master for the last page. In this case, the breaker would either have to revise the last break decisions or be modified to be able to work with the notion of a "last part" that it can automatically adjust while page decisions are considered. The latter might lead to an additional approach to the problem.

### Bringing multi-column documents into play

Looking at the following layout (with two columns) it becomes apparent that the "last page" problem cannot be solved without reevaluating page/column-break decisions in certain documents.

```+-----+ +-----+ +-----+
| x x | | x x | | x x |
| x x | | x   | | x x |
| x x | | x   | | x x |
| x x | | x   | +-----+
| x x | | x   | |YYYYY|
+-----+ +-----+ +-----+
1       2  -->  2*

+-----+ +-----+ +-----+ +-----+
| x x | | x x | | x x | |     |
| x x | | x x | | x x | |     |
| x x | | x x | | x x | |     |
| x x | | x   | | x   | +-----+
| x x | | x   | | x   | |YYYYY|
+-----+ +-----+ +-----+ +-----+
1       2  -->  2*      3```

This means that we have to find the last break point before the last page starts and restart the breaking process with adjusted BPD values from that point. However, that doesn't account for the case in the previous section. The question is probably if it has to. For most cases, we don't need to account for it (it's an exotic case after all).

Let's try to define an algorithm for the easy cases:

1. Find the last break point between the last page and the previous one.
2. Rerun the page breaking process from this break point with the "line widths" (actually the available BPD) from the "last" page.
3. If there are more parts than columns, retain the original break decisions and add a "blank" "last" page.
4. If the number of parts <= number of columns, change the page master for the last page to a "non-blank" "last" page.

5. Finalize the last page(s).

### Random Notes

• ATM, it's unknown how footnotes (and before-floats) will influence "last page" handling.

PagePositionLast (last edited 2009-09-20 23:52:18 by localhost)