Forum How do I...?

Different footers based on current page and document page count

robertb
I have a document which with a varying body length.

If the document is 1 page long, we need the "last page footer" on the bottom
if the document is many pages long, we need an "interim page footer" on the bottom of all but the last page.
All the footers have the same height.

I have tried combining float-bottom with a flowed footer, but the but the flow always overlaps the float, and setting the z-index does not work.

I tried using javascript to find boxes, but I could not find the footer boxes.

Any assistance would be appreciated.

R

mikeday
I think you can just put an element (or generated content) at the very end of the document that flows to the footer, replacing the existing footer.
robertb
Hi Mike,

I am using this:
body::after {
    content: "";
    flow: static(footer)
}

It works perfectly for multipage documents, but it does not work with 1 page documents, the footer is still there. I also tried a div at after the content, with a named page, which also does not work.
        #document_finished {
            page: last_page;
        }
        @page map:last_page {
            @bottom {
                content: none;
            }
        }

R

Edited by robertb

mikeday
Sorry for the delay, you should be able to achieve this by adding a "last" page-policy argument to the static flow, which says to use the last footer specified on the page rather than the first:
<style>
@page {
    @bottom {
        content: flow(footer, last)
    }
}

footer {
    flow: static(footer)
}

h1 {
    page-break-before: always
}
</style>
<footer>
interim page footer
</footer>
<h1>First</h1>
<h1>Second</h1>
<footer>
last page footer
</footer>

If you remove one of the headings so that it is only one page long it should work as expected.
robertb
Thanks Mike!

That works perfectly.

R