Forum Bugs

document structure for headers/footers

Anonymous
Hi,

I've been trying out Prince and so far, I am quite impressed apart from the following point:
The only way I can put headers and footers on multiple pages using flow:static is to put the actual header and footer content at the top of the html document.

i.e.
<html>
<div id="header">
header content
</div>
<div id="footer">
footer content
</div>
<div id="content">
main content
</div>
</html>

css:

@page {
@top { content: flow(header); }
@bottom {content: flow(footer); }
}

#header
{flow: static(header);}

#footer
{flow: static(footer);}

This doesn't work however, if I structure my document to accessibility guidelines and place the main content at the top of the document and the header and footer at the bottom, in this case, the header and footer are only put on the last page???

Is this a bug, and if so, when will it be fixed
Anonymous
This is actually not a bug.
An element that sets flow:static(_) will be used as the header/footer on the current page and be carried onto the following pages until another such element is seen. This way, you can define multiple headers/footers in a document. For example, different chapters can have different headers/footers.
If you want headers/footers to be printed on all pages but don't want the header/footer elements to be at the beginning of the document, you can always try to define the header/footer directly in your CSS:
@page {
    @top { content: "Header content" }
    @bottom { content: "Footer content" }
}

Xuehong
Anonymous
Hi,

Thanks for your reply but I really need the headers and footers in markup and styled (I'm trying to put a multi-line address at the top of each page and terms and conditions at the bottom of each page.) It does work well when put at the top of the html, but for accessibility, shouldn't really be put at the top of the code.
Is there another way round this. I've tried named pages as well, but they just don't pick it up if its at the end of the html
mikeday
Hi Sam,

There is no way to take content from the end of the document and move it to the beginning of the document at this time. In the future we may extend the flow mechanism to support this behaviour.

In the meantime, the only solution is to move the content to the beginning of the document, either by hand or with a transformation or script.

Note that if the multiline address that you wish to place in the header does not have complex styling you could place it in the CSS like this:

@page {
    @top { content: "line1\A line2\A line3" }
}

The "\A" is a CSS escaped newline character.
mikeday
Hi Sam,

Today we have released a new alpha version of Prince that includes many new features, including a new optional parameter for flow that allows you to take content from the end of your document and flow it to a header/footer from the beginning of your document:
flow: static(header, start)

Let us know how it goes! :)

Best regards,

Michael
rolandw
I am using Prince 6.0 rev 4 and was hoping that this "start" feature would be implemented by now (it is 18 months later...) but I can't see anything about it. Has it?

I have a nice first page footer that works very well. If I put it at the top of the XHTML then it appears at the footer on that page. However, if I preview the XHTML in a browser it appears in the wrong place. Ideally I would put the footer div at the bottom of my XHTML so that previewing it works but this falls apart if the document is more than 2 pages long.

An alternate would be to get the footer text to not appear in a browser but to appear in the pdf... If the footer is dynamic (which in this case it needs to be as I am using a table in the footer) I can't define the footer in the @page@bottom-left (for example) margin.

Any ideas?
mikeday
You can use the "start" keyword with flow as described in my previous post. Alternatively, you could hide things from the browser by placing them inside a print-specific style sheet:
@media print {
    .footer { ... }
}
@media screen {
    .footer { display: none }
}

This allows you to write style rules that will be applied when printing the document but ignored when displaying the document on the screen.
thomasdumm
Hello!

I tried to follow your instruction and used "\A" to get a line break in the header. It did not show the desired result. I aim in having a two line header with generated content:

@top-left {
content: string(book-title) "\A" string(chapter-title);
}

Do you have any idea why I do not see a two line header? I used princexml 9.0r4 evaluation version.

Kindest regards
Thomas
rolandw
From Stackoverflow:

"A string cannot directly contain a newline. To include a newline in a string, use an escape representing the line feed character in ISO-10646 (U+000A), such as "\A" or "\00000a". This character represents the generic notion of "newline" in CSS."

(http://stackoverflow.com/questions/9062988/newline-character-sequence-in-css-content-property)

So why not test out the \00000a instead.
mikeday
Apply "white-space: pre-line" to the @top-left, so that newlines cause line breaks.
thomasdumm
The "white-space: pre-line" did the trick. Then it works with \00000a or \A. Thank you for your help!