XSL-FO uses page templates called "Page Masters" to define the layout of pages.
XSL-FO Page Templates
XSL-FO uses page templates called "Page Masters" to define the layout of pages. Each template must have a unique name:
<fo:region-body margin="5in" />
<fo:region-body margin-left="2in" margin-right="3in" />
<fo:region-body margin-left="3in" margin-right="2in" />
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 called "intro". It could be used as a template for introduction pages.
The second and third templates are called "left" and "right". They could be used as templates for even and odd page numbers.
XSL-FO Page Size
XSL-FO uses the following attributes to define the size of a page:
- page-width defines the width of a page
- page-height defines the height of a page
XSL-FO Page Margins
XSL-FO uses the following attributes to define the margins of a page:
- margin-top defines the top margin
- margin-bottom defines the bottom margin
- margin-left defines the left margin
- margin-right defines the right margin
- margin defines all four margins
XSL-FO Page Regions
XSL-FO uses the following elements to define the regions of a page:
- region-body defines the body region
- region-before defines the top region (header)
- region-after defines the bottom region (footer)
- region-start defines the left region (left sidebar)
- region-end defines the right region (right sidebar)
Note that the region-before, region-after, region-start, and region-end is a part of the body region. To avoid text in the body region to overwrite text in these regions, the body region must have margins at least the size of these regions.
This is an extract from an XSL-FO document:
page-height="210mm" margin-top="1cm" margin-bottom="1cm"
The code above defines a "Simple Page Master Template" with the name "A4".
The width of the page is 297 millimeters and the height is 210 millimeters.
The top, bottom, left, and right margins of the page are all 1 centimeter.
The body has a 3 centimeter margin (on all sides).
The before, after, start, and end regions (of the body) are all 2 centimeters.
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 width of the page itself:
297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm.
Note that the regions (region-start and region-end) are not a part of the calculation. As described earlier, these regions are parts of the body.
Thank You For Helping Us!
Your message has been sent to W3Schools.