XSL-FO page
XSL-FO uses page templates called "Page Masters" to define the layout of the page.
XSL-FO Page Templates
XSL-FO uses page templates named "Page Masters" to define the layout of the page. Each template must have a unique name:
<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>
above In the 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 an introductory page.
The second and third templates are named "left" and "right". They are available as page templates for even and odd numbered pages.
XSL-FO Page Size
XSL-FO uses the following attributes to define the size of the page:
- ##page- width defines the width of the page
- page-height defines the height of the page
XSL-FO Page MarginsXSL-FO Use the following attributes to define the margins of the page:
- margin-top Define the top margin ##margin- bottom defines the bottom margin
- margin-left defines the left margin
- margin-right defines the right margin
- margin defines the margins on all sides
XSL-FO Use the following elements to define the regions of the page :
- region-body Define the body 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 defines the right region (right column)
- Please note that region-before, region-after, region-start, and region-end are part of the main area. To prevent the text in the main area from covering the text in these areas, the margins of the main area must be at least equal to the size of the other areas.
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">
<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 page named "A4" "Simple Page Master Template".
The width of the page is 297 mm and the height is 210 mm.
The four margins of the page (top margin, bottom margin, left margin, right margin) are all 1 cm.
The margins of the body are 3 cm (all four sides).
The before, after, start and end areas of the main body are all 2 cm.
The width of the body in the above example can be calculated by subtracting the left and right margins from the page width and the margins of region-body:
297mm - (2 x 1cm) - ( 2 x 3cm) = 297mm - 20mm - 60mm = 217mm
Please note that region (region-start and region-end) are not included in the calculation. As explained before, these regions are components of the main body.