Latest web development tutorials

XSL-FO page

XSL-FO uses page templates called "Page Masters" to define the layout of the page.

XSL-FO page template (Page Templates)

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

<fo:simple-page-master master-name="intro">
<fo:region-body margin="5in" />

<fo:simple-page-master master-name="left">
<fo:region-body margin-left="2in" margin-right="3in" />

<fo:simple-page-master master-name="right">
<fo:region-body margin-left="3in" margin-right="2in" />

In the example above, the three <fo: simple-page-master> element defines three different templates. Each template (page-master) has a different name.

The first template named "intro". It can be used as a template for introduction pages.

The second and third templates called "left" and "right". They can be as even and odd numbered pages template.

XSL-FO Page Size (Page Size)

XSL-FO using the following attributes define the size of the page:

  • The width of the page-width custom page
  • Highly page-height custom page

XSL-FO page margins (Page Margins)

XSL-FO using margin following attribute definition page:

  • The margin-top custom margins
  • Under the definition of margin-bottom margins
  • margin-left to define the left margin
  • margin-right to define the right margin
  • margin defines all sides margins

XSL-FO Region (Page Regions)

XSL-FO using the following element defines a page area:

  • region-body defined body region
  • region-before-defined area at the top (header)
  • region-after the definition of the base region (footer)
  • region-start area is defined on the left side (left column)
  • region-end definition of the right of the area (right column)

Please note, region-before, region-after, region-start and region-end is part of the main area. To avoid text body text area to cover these areas, the main area of ​​the margin at least equal to the size of other districts.

Margins and page layout

XSL-FO instances

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"/>

The above code defines a name for the "A4" of "Simple Page Master Template".

Page width is 297 mm, height 210 mm.

Four page margins (margins on the bottom, left margin, right margin) is 1 cm.

Margins body is 3 cm (all four sides).

before the body, after, start and end zones are 2 cm.

The width of the main examples above may be reduced by about margins and the region-body margins calculated by the width of the page:

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

Please note, region (region-start and region-end) is not counted. As previously explained earlier, these zones (region) is an integral part of the body.