Table of Contents
Getting your printed output to look the way you want may require more DocBook customization than for HTML output. HTML output can be styled using a separate CSS stylesheet applied to the generated HTML files. For print output, you need to specify style properties in the DocBook XSL stylesheet for FO output. In Chapter 7, Printed output options you saw how to set parameters on the command line to change some formatting features. Given the number and type of parameters that need to be set, a customization layer makes more sense for print customization.
The basic framework for a print customization is an XSL stylesheet that imports the standard DocBook FO stylesheet and then adds your changes. Here is a simple example that just sets some page parameters.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> <xsl:import href="../../docbook-xsl-1.68.1/fo/docbook.xsl"/> <xsl:param name="page.height.portrait">9in</xsl:param> <xsl:param name="page.width.portrait">7in</xsl:param> <xsl:param name="page.margin.inner">0.75in</xsl:param> <xsl:param name="page.margin.outer">0.50in</xsl:param> <xsl:param name="page.margin.top">0.17in</xsl:param> <xsl:param name="page.margin.bottom">0.50in</xsl:param> </xsl:stylesheet>
In addition to letting you set parameters, such a customization layer lets you add properties to attribute sets and customize individual stylesheet templates.
The root.properties
attribute-set lets you assign XSL-FO properties that apply to the whole
document. For example, you might want to globally turn off
hyphenation, or print everything in blue type. By default, the
stylesheet puts several important properties in this attribute
set. Most of the property values can be changed with stylesheet
parameters.
Table 12.1. root.properties attribute-set
FO property | From stylesheet parameter | Default value |
---|---|---|
font-family | body.font.family | serif |
font-size | body.font.size | 10pt |
text-align | alignment | justify |
line-height | line-height | normal |
font-selection-strategy | No parameter | character-by-character |
Generally you should use the appropriate parameter to reset any of these properties. But if you want to add new properties, you can do that by putting an attribute-set of the same name in your customization layer. Since attribute-sets of the same name are merged, your new properties will be added to the default properties. Here is an example that sets the font color to blue.
<xsl:attribute-set name="root.properties"> <xsl:attribute name="color">blue</xsl:attribute> </xsl:attribute-set>
When processed, the attributes in this attribute-set are placed in the fo:root
element in the XSL-FO output:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="serif"
font-size="10pt" text-align="justify" line-height="normal"
color="blue" font-selection-strategy="character-by-character"
language="en">
The resulting PDF file will have all blue type. Keep in mind that only properties that are inheritable can be set this way. For example, the widows
and orphans
properties are inheritable and can be changed from their default values of 2. See a good XSL-FO reference to see which properties are inheritable. The root.properties
attribute-set first appeared in version 1.61 of the
stylesheets.
DocBook XSL: The Complete Guide - 3rd Edition | PDF version available | Copyright © 2002-2005 Sagehill Enterprises |