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) 2016, HerongYang.com, All Rights Reserved.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <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"
 <fo:page-sequence master-reference="content">
  <fo:static-content flow-name="header">
   <fo:block border-bottom-width="1px" border-bottom-style="solid" 
  <fo:flow flow-name="body">
   <fo:block>Hello world!</fo:block>
   <fo:block break-before="page">Text on the new page...</fo:block>

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:

C:\herong>\fop\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:

XSL-FO Example Output - Page-Break-with-Header.fo

Last update: 2016.

Table of Contents

 About This XSL-FO Tutorial Book

 Introduction of XSL-FO

 Apache™ FOP (Formatting Objects Processor)

 RenderX XEP as an XSL-FO Tool

 Introduction of Area Model

XSL-FO Document Basics and Examples

 Document Top Level Structure Rules

 Example - hello.fo

Example - Page-Break-with-Header.fo

 Example - Cover-Page-and-Two-Columns.fo

 Page Layout Masters

 Block-Level Formatting Objects

 Inline-Level Formatting Objects

 Including Graphics in XSL-FO document

 Table of Rows and Columns

 List, Item, Label, and Body

 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

 RenderX XEP Font Configurations


 PDF Printing Version