Real World XML (2nd Edition)

Using a Page Master: fo:simple-page-master

A page master is a master template that is used to generate a page, and it specifies the actual layout of the page. You can use a page master whenever you want to in a document. Each page master has a unique name .

In the current XSL specification, there is only one kind of page master, the fo:simple-page-master object; in the future, the XSL specification may support additional page masters. You use the fo:simple-page-master object to generate pages and define the geometry of the page.

To set the overall geometry of the page, you can use these properties of the fo:simple-page-master object:

  • Common margin properties for blocks: margin-top , margin-bottom , margin-left , margin-right , spa ce-before , space-after , start-indent , end-indent

  • master-name

  • page-height

  • page-width

  • reference-orientation

  • writing-mode

In ch14_02.xsl, I'll name the simple page master page using the master-name property. When I want to create pages using this master, I'll be able to refer to it by name. I'll also specify the page dimensions and margins like this:

<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0'> <xsl:template match="PLANETS"> <fo:root> <fo:layout-master-set> <fo:simple-page-master master-name="page" page-height="400mm" page-width="300mm" margin-top="10mm" margin-bottom="10mm" margin-left="20mm" margin-right="20mm"> . . .

Besides laying out the margins of a page, a fo:simple-page-master has children that specify one or more regions in the page, letting you customize the layout in detail.

Категории