Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XSL-FO Pages

XSL-FO Pages


XSL-FO uses page templates called "Page Masters" to define page layouts.


XSL-FO Page Templates

XSL-FO uses page templates called "Page Masters" to define page layouts. Each template must have a unique name:

In the example above, 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 the introduction page.

The second and third templates are named "left" and "right". They can be used as templates for even and odd page numbers.


XSL-FO Page Size

XSL-FO uses the following properties to define the page size:


XSL-FO Page Margins

XSL-FO uses the following properties to define the page margins:


XSL-FO Page Regions

XSL-FO uses the following elements to define the page regions:

Note that region-before, region-after, region-start, and region-end are part of the body region. To prevent the text in the body region from covering the text in these regions, the margins of the body region must be at least equal to the size of the other regions.


XSL-FO Example

This is a fragment extracted from an XSL-FO document:

page-height="210mm" margin-top="1cm" margin-bottom="1cm"

margin-left="1cm" margin-right="1cm">

The code above defines a "Simple Page Master Template" named "A4".

The page width is 297 mm and the height is 210 mm.

The four margins of the page (top, bottom, left, right) are all 1 cm.

The margins of the body are 3 cm (on all four sides).

The before, after, start, and end areas of the body are all 2 cm.

The width of the body in the example above can be calculated by subtracting the left and right margins and the region-body margins from the page width:

297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm

Note that regions (region-start and region-end) are not counted. As explained earlier, these regions are part of the body.