Saucer flying header and footer

Viewed 80

I use the header and footer in saucer flying. It works well. The current state works where I use the div with header or footer, I have from there until the end of the file header or footer. I've tried this, but it doesn't work. { content: element(header, last-except)} or { content: element(header, first-except)}

This is my code style:

div.header {
   display: block; 
   text-align: center;
   position: running(header);
}

div.footer {
   display: block; 
   text-align: center;
   position: running(footer);
}

@page {
   @top-center { content: element(header) }
} 

@page {
   @bottom-center { content: element(footer) }
}

HTML:

<div class="header">
</div>

I would like to have a header or footer only, for example from 2 to 5 pages of pdf. Is there a way to stop the generation on each page of the pdf?

Thanks.

1 Answers

With flying-saucer, you can only set a different header or footer for the first page, using the :first pseudo-class.

.header {position: running(header);}
.footer {position: running(footer);}

.headerfirst {position: running(headerfirst);}
.footerfirst {position: running(footerfirst);}

@page :first {
    @top-center { content: element(headerfirst) }
    @bottom-center { content: element(footerfirst) }
}
@page {
    @top-center { content: element(header) }
    @bottom-center { content: element(footer) }
}

Unfortunately, the :last pseudo-class doesn't work.

Related