Forum How do I...?

Header on custom page-breaks

madastro
Is it possible to have headers on page-breaks that we define?

For example:
page 1:
<header>
<h3>
<content>

page 2:
<content>

page 3:
<header>
<h3>
<content>

We've set the page-breaks to happen only if the content has an <h3>

h3 { page-break-before: always }

but we'd like to add a header as well, is this possible?
FYI: Header on the first page is currently part of the markup and is not using princexml's flow mechanism.
mikeday
So what if you just flow the header element to the @top margin box?
madastro
Wouldn't that make the headers show up on all pages? instead of just those pages with the <h3>?
mikeday
Oh, right. In that case, you could clear the header immediately after the h3, eg. by flowing an empty block to the header. This could be generated from the ::after pseudo-element.
madastro
Thank you, I will try that.
madastro
Hi, I've managed to make the header appear on all the pages but got stuck on the "flowing an empty block to the header" part, could you post an example code on how to do this please.
mikeday
Try something like this:
h3::after {
    content: "";
    flow: static(header)
}
madastro
hi Mike, sorry, but does this need to be in a @page {...} section? because when I added it to the CSS, only the first page with an <h3> has the header, the succeeding pages with <h3> is not getting the header.

Just to clarify the issue:
We have a PDF that has a letterhead and different divisions, and each division has a header <h3> and a couple of blocks of content which may or may not extend to another page, hence the header could appear on page 2 or 5, etc.

Currently, we're able to set it up so that if Prince encounters an <h3> header it will start on a new page, but now we wanted it to have the letterhead as well. I'm very new at this and I've been trying, since yesterday, to find a solution from the forums as well as the user guide, but was not able to find a similar issue which has been addressed. So, I just want to confirm if I am missing any procedure to make the above code work in my case and if you could point me to the right direction please.

I'd like to send an example but I'm not sure I'm allowed, so please let me know if you require additional information.

madastro
Just to add, here's how the logic goes:
First page:
- print letterhead
- print first <h3> title
- print content
- does the next content have an <h3> title?
if yes - start a new page and print letterhead, <h3> title and content
if not - continue printing content
mikeday
If you want the header to appear on every page that begins with a <h3>, and not appear on pages that don't begin with a <h3>, then you could use a different approach:
@page mypage:first {
    @top { content: flow(header) }
}

body { page: mypage }

h3 { prince-page-group: start }

div.header { flow: static(header) }

This no longer requires the ::after pseudo-element.
madastro
Thank you, that one worked.
Cheers.