Header and footer

In this example the header of a page is generated. The footer has to be treated accordingly.

Various concepts being useful for the formation of the header of a page are demonstrated. For structuring the header, the table concept is used.

Source code

<fo:page-sequence master-reference="PageMaster.Content" initial-page-number="1">  ❶
...             
<fo:static-content flow-name="Content-right-before">                              ❶
   <fo:table font-size="10pt" width="140mm">                                      ❷
      <fo:table-column column-number="1" column-width="23mm"/>
      <fo:table-column column-number="2" column-width="110mm"/>
      <fo:table-column column-number="3" column-width="7mm"/>
      <fo:table-body>
         <fo:table-row>
            <fo:table-cell column-number="1" display-align="after">
               <fo:block>
                  <fo:external-graphic src="logo.eps" content-width="20mm"/>     ❸ 
               </fo:block>
            </fo:table-cell>
            <fo:table-cell column-number="2" display-align="after">              ❹
               <fo:block>
                  <fo:retrieve-marker 
                   retrieve-class-name="Headline-Level1"
                   retrieve-position="first-including-carryover"
                   retrieve-boundary="page-sequence"/>
                </fo:block>
             </fo:table-cell>
             <fo:table-cell column-number="3" display-align="after">             ❺
                <fo:block text-align="right">
                   <fo:page-number/>
                </fo:block>
             </fo:table-cell>
          </fo:table-row>
       </fo:table-body>
    </fo:table>
</fo:static-content>
...
</fo:page-sequence>

❶ The header has to be assigned to a page sequence and there to a static region, in this example in the page sequence PageMaster.Content to the region Content-right-before. The page sequence begins with the page number 1. If the page counting of a preceeding page sequence is continued, the attribute would not be set here again.

❷ This is the – invisible – table in which the individual elements of the header are arranged. It has three column specifications, each containing the width of the columns. For the table cells is specified that the cell contents are arranged at the bottom margin of the cell (display-align="after"). The table only has one line.

❸ The first (left) cell contains a graphic, the logo (logo.eps). The graphic is aligned at the left margin because the default value for the alignment in blocks is start (which means left). The logo is scaled up to the width of 20 mm. So it remains a distance of 3 mm between the logo and the following block.

❹ The central cell contains the running head. For the generation and formation of running heads see the relevant section.

❺ The right cell contains the running page number. It is aligned to the right in order to end with the print space margin on the right side.

Footers can be treated accordingly. Of course, the contents have to be arranged in an appropriate static region.

<< back next >>

Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo@dpunkt.de