XML technologies / DocBook / Generating FO (PDF) / Editing headers and footers / Adding a graphic
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
To add a graphic to a header or footer, copy the original and adapt it to your needs. The following example shows how an SVG graphic is inserted with the FO element fo:instream-foreign-object.
Example: Adding a centred graphic to the footer
<xsl:template name="footer.content">
<xsl:param name="pageclass" select="''"/>
<xsl:param name="sequence" select="''"/>
<xsl:param name="position" select="''"/>
<xsl:param name="gentext-key" select="''"/>
<fo:block>
<!-- pageclass can be front, body, back -->
<!-- sequence can be odd, even, first, blank -->
<!-- position can be left, center, right -->
<xsl:choose>
<xsl:when test="$position = 'center'">
<fo:instream-foreign-object content-height="1.2cm">
<svg xmlns="http://www.w3.org/2000/svg" width="2cm" height="1cm">
<circle r="50%" cx="50%" cy="50%" fill="orange"/>
<circle r="25%" cx="50%" cy="50%" fill="red"/>
<text x="50%" y="60%" text-anchor="middle" font-style="italic">L</text>
</svg>
</fo:instream-foreign-object>
</xsl:when>
<!-- ... -->
</xsl:choose>
</xsl:template>If your FO formatter does not support SVG graphics or you want to use a bitmap, replace the entire fo:instream-foreign-object element with the following lines:
<fo:external-graphic content-height="1.2cm">
<xsl:attribute name="src">
<xsl:call-template name="fo-external-image">
<xsl:with-param name="filename" select="$image.footer.filename"/>
</xsl:call-template>
</xsl:attribute>
</fo:external-graphic>Set the parameter image.footer.filename in your customization file to the graphic file name. The template fo-external-image wraps the file name in url(...) when necessary. Some FO formatters incorrectly prefer the notation without url.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top