Page layout

The result from of our Hello, World ... code is not very impressive. In order to develop more elaborated examples we have to understand the underlying layout model being defined in a fo:simple-page-master element. First of all FO allows for subdividing a physical page into different regions:

Figure 906. Regions being defined in a page. Create comment in forum

The most important area in this model is denoted by fo:region-body. Other regions like fo:region-before are typically used as containers for meta information such as chapter headings and page numbering. We take a closer look to the fo:region-body area and supply an example of parameterization:

Figure 907. A complete FO parameterizing of a physical page and the fo:region-body. Create comment in forum
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  font-size="6pt">

  <fo:layout-master-set> <fo:simple-page-master master-name="simplePageLayout" ❷
      page-width  = "50mm" page-height   = "80mm"
      margin-top  = "5mm"  margin-bottom = "20mm"
      margin-left = "5mm"  margin-right  = "10mm">

      <fo:region-body ❸
        margin-top  = "10mm" margin-bottom = "5mm"
        margin-left = "10mm" margin-right  = "5mm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="simplePageLayout"> <fo:flow flow-name="xsl-region-body"> <fo:block space-after="2mm">Dumb text .. dumb text.</fo:block> <fo:block space-after="2mm">Dumb text .. dumb text.</fo:block> <fo:block space-after="2mm">Dumb text .. dumb text.</fo:block> <fo:block space-after="2mm">Dumb text .. dumb text.</fo:block> </fo:flow>
  </fo:page-sequence>
</fo:root>

As the name suggests multiple layout definitions can appear here. In this example only one layout is defined.

Each layout definition carries a key attribute master-name being unique with respect to all defined layouts appearing in the <fo:layout-master-set>. We may thus call it a primary key attribute. The current layout definition's key has the value simplePageLayout. The length specifications appearing here are visualized in Figure 908, “Parameterizing page- and region view port. All length dimensions are in mm. ” and correspond to the white rectangle.

Each layout definition must have a region body being the region in which the documents main text flow will appear. A layout definition may also define top, bottom and side regions as we will see later. The body region is shown with pink background in Figure 908, “Parameterizing page- and region view port. All length dimensions are in mm. ”.

A FO document may have multiple page sequences for example one per each chapter of a book. It must reference an existing layout definition via its master-reference attribute. So we may regard this attribute as a foreign key targeting the set of all defined layout definitions.

A flow allows us to define in which region output shall appear. In the current example only one layout containing one region of type body definition being able to receive text output exists.

A <fo:block> element may be compared to a paragraph element <p> in HTML. The attribute space-after="2mm" adds a space of two mm after each fo:block container.

The result looks like:

Figure 908. Parameterizing page- and region view port. All length dimensions are in mm. Create comment in forum