XSL-FO Page
- Previous Page XSLFO Stream
- Next Page XSLFO Block
XSL-FO uses a page template named "Page Masters" to define the page layout.
XSL-FO page template
XSL-FO uses a page template named "Page Masters" to define the page layout. Each template must have a unique name:
<fo:simple-page-master master-name="intro"> <fo:region-body margin="5in" /> </fo:simple-page-master> <fo:simple-page-master master-name="left"> <fo:region-body margin-left="2in" margin-right="3in" /> </fo:simple-page-master> <fo:simple-page-master master-name="right"> <fo:region-body margin-left="3in" margin-right="2in" /> </fo:simple-page-master>
In the above example, three <fo:simple-page-master> elements define three different templates. Each template (page-master) has a different name.
The first template is named "intro". It can be used as a template for introducing pages.
The second and third templates are named "left" and "right". They can be used for even and odd page numbers on the pages.
XSL-FO Page Size
XSL-FO uses the following attributes to define page size:
- page-width
- Define the width of the page
- page-height
- Define the height of the page
XSL-FO Page Margins
XSL-FO uses the following attributes to define page margins:
- margin-top
- Define the top margin
- margin-bottom
- Define the bottom margin
- margin-left
- Define the left margin
- margin-right
- Define the right margin
- margin
- Define the margins of all sides
XSL-FO Page Regions
XSL-FO uses the following elements to define page areas:
- region-body
- Define the main area
- region-before
- Define the top area (header)
- region-after
- Define the bottom area (footer)
- region-start
- Define the left area (left column)
- region-end
- Define the right area (right column)
Note:region-before, region-after, region-start, and region-end are part of the main area. To avoid the text of the main area from overlapping these regions, the margins of the main area must be at least equal to the size of other areas.
Illustration:

XSL-FO Example
This is a fragment extracted from an XSL-FO document:
<fo:simple-page-master master-name="A4"> page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm"> <fo:region-body margin="3cm"/> <fo:region-before extent="2cm"/> <fo:region-after extent="2cm"/> <fo:region-start extent="2cm"/> <fo:region-end extent="2cm"/> </fo:simple-page-master>
The above code defines a 'Simple Page Master Template' named 'A4'.
The width of the page is 297 millimeters, and the height is 210 millimeters.
The four margins of the page are all 1 centimeter.
The margin of the main body is 3 centimeters (all four sides).
The before, after, start, and end regions are all 2 centimeters.
The width of the main body in the above example can be calculated by subtracting the page width, left and right margins, and the margin of region-body.
297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm.
Note:The region (region-start and region-end) is not calculated. As explained earlier, these regions are part of the main body.
- Previous Page XSLFO Stream
- Next Page XSLFO Block