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

This section provides a tutorial example of an XSL-FO document structure, Cover-Page-and-Two-Columns.fo, which declares two page layouts: one for the cover page and one for content pages. It also specifies that content pages to be formatted in two columns.

Now let's take a look at our third example, Cover-Page-and-Two-Columns.fo, which represents an XSL-FO document with two page master layouts: one for the cover page and one for content pages:

<?xml version="1.1" encoding="utf-8"?>
<!-- Cover-Page-and-Two-Columns.fo
 - Copyright (c) 2006 HerongYang.com. All Rights Reserved.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:simple-page-master master-name="cover" margin-top="4in">
   <fo:region-body region-name="body"/>
  <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.25in"/>
 <fo:page-sequence master-reference="cover">
  <fo:flow flow-name="body">
   <fo:block font-size="20pt" font-weight="bold" text-align="center">
    The Wind in the Willows
 <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">The Wind in the Willows</fo:block>
  <fo:flow flow-name="body">
   <fo:block span="all" font-size="14pt" font-weight="bold" 
    text-align="center" padding-before="16pt">
   <fo:block space-before="8pt">
    The Mole had been working very hard all the morning, 
    spring-cleaning his little home. First with brooms, then with 
    dusters; then on ladders and steps and chairs, with a brush and 
    a pail of whitewash; till he had dust in his throat and eyes, and
    splashes of whitewash all over his black fur, and an aching back 
    and weary arms. Spring was moving in the air above and in the 
    earth below and around him, penetrating even his dark and lowly 
    little house with its spirit of divine discontent and longing. 
    It was small wonder, then, that he suddenly flung down his brush 
    on the floor, said 'Bother!' and 'O blow!' and also 'Hang 
    spring-cleaning!' and bolted out of the house without even waiting
    to put on his coat...
   <fo:block span="all" font-size="14pt" font-weight="bold" 
    text-align="center" padding-before="16pt">
   <fo:block space-before="8pt">
    'Ratty,' said the Mole suddenly, one bright summer morning, 'if 
    you please, I want to ask you a favour.'
   <fo:block space-before="8pt">
    The Rat was sitting on the river bank, singing a little song. He 
    had just composed it himself, so he was very taken up with it, and
    would not pay proper attention to Mole or anything else. Since 
    early morning he had been swimming in the river, in company with 
    his friends the ducks...
   <fo:block span="all" font-size="14pt" font-weight="bold" 
    text-align="center" padding-before="16pt">

Notes about this example:

We can run Apache FOP to process Cover-Page-and-Two-Columns.fo into a PDF file, Cover-Page-and-Two-Columns.pdf:

herong> fop -fo Cover-Page-and-Two-Columns.fo \
  -pdf Cover-Page-and-Two-Columns.pdf

Then open Cover-Page-and-Two-Columns.pdf with Adobe Acrobat Reader, we will see the first page is nicely formatted as a cover page. The second page displays some samples of title line and text in two columns as shown below:

XSL-FO Example Output - Cover-Page-and-Two-Columns.fo
XSL-FO Example Output - Cover-Page-and-Two-Columns.fo

Table of Contents

 About This 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

 Converting HTML to PDF


 Full Version in PDF/ePUB