XSL-FO Page
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:
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 introduction pages.
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 attributes to define the page size:
page-widthdefines the width of the pagepage-heightdefines the height of the page
XSL-FO Page Margins
XSL-FO uses the following attributes to define the page margins:
margin-topdefines the top marginmargin-bottomdefines the bottom marginmargin-leftdefines the left marginmargin-rightdefines the right marginmargindefines the margin for all sides
XSL-FO Page Regions
XSL-FO uses the following elements to define page regions:
region-bodydefines the body regionregion-beforedefines the top region (header)region-afterdefines the bottom region (footer)region-startdefines the left region (left sidebar)region-enddefines the right region (right sidebar)
Note that region-before, region-after, region-start, and region-end are part of the body region. To prevent text in the body region from overlapping with text in these regions, the margins of the body region should be at least as large as the dimensions of the other regions.
XSL-FO Example
Here is an excerpt from an XSL-FO document:
The code above defines a "Simple Page Master Template" named "A4".
The page width is 297 millimeters and the height is 210 millimeters.
The page margins (top, bottom, left, right) are all 1 centimeter.
The body margin is 3 centimeters (all four 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 margins of the region-body from the page width:
297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm
Note that the regions (region-start and region-end) are not included in the calculation. As mentioned earlier, these regions are part of the body.