Page Layout and Page Sequence Mapping

This section provides a tutorial example on how to apply a layout of 'simple-page-master' to a 'page-sequence'. The master-reference must match the master-name. And flow-name must match the region-name.

In previous tutorials, we have learned how to declare layouts with simple-page-master. In this tutorial, we will look at how to apply a layout to a page sequence.

Applying a layout of "simple-page-master" to a page sequence generated from "page-sequence" consists of 3 types of mapping:

Layout Mapping (page-sequence[@master-reference] = simple-page-master[@master-name]) - This mapping determines which "simple-page-master" to use when generating pages from the content of this "page-sequence". This mapping is required.

Body Flow Mapping (page-sequence/flow[@flow-name] = simple-page-master/region-body[@region-name]) - This mapping determines which flow to use to fill the "body" region. If the flow is "longer" than the "body" region of first page, more pages will be generated using the same layout to allow the flow to overflow to multiple pages.

Static Flow Mapping (page-sequence/static-content[@flow-name] = simple-page-master/region-before[@region-name] or simple-page-master/region-after[@region-name] or simple-page-master/region-start[@region-name] or simple-page-master/region-end[@region-name]) - This mapping determines which flow to use to fill a "side" region on each page repeatedly. If the flow is "longer" than the "side" region, it will overflow to the "body" region.

To demonstrate how a "simple-page-master" can be applied to a "page-sequence", I wrote the following example XSL-FO document, Page-Layout-Page-Sequence-Mapping.fo, to generate a sequence of pages with a simple layout: a "body" region and a "footer" region:

<?xml version="1.1" encoding="utf-8"?>
<!-- Page-Layout-Page-Sequence-Mapping.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="page" margin="0.25in" 
   page-height="2.3in" page-width="2.1in">
   <fo:region-body region-name="body" margin="0.25in"
   background-color="#eeeeee"/>
   <fo:region-after region-name="footer" extent="0.2in"/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="page">
  <fo:static-content flow-name="footer">
   <fo:block font-size="8pt">herongyang.com</fo:block>
  </fo:static-content> 
  <fo:flow flow-name="body">
   <fo:block>
    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>
  </fo:flow>
 </fo:page-sequence>
</fo:root>

You can process this example XSL-FO document with Apache FOP tool to generate pages in PDF format:

herong> fop -fo Page-Layout-Page-Sequence-Mapping.fo \
   -pdf Page-Layout-Page-Sequence-Mapping.pdf

When you open the PDF file, you should see a number of pages with the same layout:

Page Layout and Page Sequence Mapping
Page Layout and Page Sequence Mapping

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

Page Layout Masters

 Layout Declarations

 simple-page-master - Simple Page Layout

 simple-page-master Attributes and Sub Elements

 simple-page-master/region-body Sub Element

 region-before and region-after Sub Elements

 region-start and region-end Sub Elements

 "Body" Region Margin and "Side" Region Extent

 Precedence of Side Region Corners

Page Layout and Page Sequence Mapping

 What Is "page-sequence-master"

 Layout Sequence Example - Cover and Content

 Wheat Is "repeatable-page-master-alternatives"?

 Layout Sequence Example - Odd and Even Pages

 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

 References

 Full Version in PDF/ePUB