XSL-FO Tutorials - Herong's Tutorial Examples - v2.25, by Herong Yang
Example - Page-Break-with-Header.fo
This section provides a tutorial example of an XSL-FO document structure, Page-Break-with-Header.fo, which declares a simple page layout with a body region and a header region. It also specifies a flow of blocks to be presented in the body region in a sequence of 2 pages with static header block on each page.
Now let's take a look at our second example, Page-Break-with-Header.fo, which represents an XSL-FO document with some simple features like page break and pager header:
<?xml version="1.1" encoding="utf-8"?> <!-- Page-Break-with-Header.fo - Copyright (c) 2006 HerongYang.com. All Rights Reserved. --> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="content" margin="0.5in"> <fo:region-body region-name="body" margin-top="0.5in"/> <fo:region-before region-name="header" extent="0.5in" background-color="#eeeeee"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="content"> <fo:static-content flow-name="header"> <fo:block border-bottom-width="1px" border-bottom-style="solid" text-align="end">Page-Break-with-Header.fo</fo:block> </fo:static-content> <fo:flow flow-name="body"> <fo:block>Hello world!</fo:block> <fo:block break-before="page">Text on the new page...</fo:block> </fo:flow> </fo:page-sequence> </fo:root>
Notes about this example:
We can run Apache FOP to process Page-Break-with-Header.fo into a PDF file, Page-Break-with-Header.pdf:
herong> fop -fo Page-Break-with-Header.fo -pdf Page-Break-with-Header.pdf
Then open Page-Break-with-Header.pdf with Adobe Acrobat Reader, and scroll to the second page, we will see the "Text on the new page..." message rendered on the second page with 0.5 inch margin and a nice header as shown below:
Table of Contents
Apache™ FOP (Formatting Objects Processor)
►XSL-FO Document Basics and Examples
Document Top Level Structure Rules
►Example - Page-Break-with-Header.fo
Example - Cover-Page-and-Two-Columns.fo
Block-Level Formatting Objects
Inline-Level Formatting Objects
Including Graphics in XSL-FO document
Floating Blocks - "float" and "footnote"
Hyperlinks, Table of Contents and Indexes
Headers and Footers using "static-content"
Font Attributes and Font Families
Apache FOP Font Configurations