[publican-list] Custom Header/Footer

Josh Kayse josh.kayse at gtri.gatech.edu
Wed Dec 9 16:39:34 UTC 2009


On 11/23/2009 04:03 PM, Paul Morgan wrote:
> On Mon, Nov 23, 2009 at 03:52:12PM -0500, Josh Kayse wrote:
>    
>> I'm attempting to switch our documentation to publican at my workplace
>> and was wondering if publican supports custom headers/footers on each
>> page for PDF output or top and bottom of HTML output.  Could I use the
>> override.css for the HTML output?  We want to include something like "Our
>> Company" at the top and bottom of each page.
>>      
> Here's a stylesheet I hacked together that has running footers and
> headers. The stylesheet belongs in a "brand" directory, such as
> /usr/share/publican/xsl/mybrand/pdf.xsl
>
> hth,
> -paul
>
>
>    
<snip>

Thanks!  That works great.  The only problem I'm running in to now is I 
cannot seem to get the header/footer to show up on the first page.  
Here's my current version of the pdf.xsl

Thanks!
-josh

<?xml version='1.0'?>

<!--
         Copyright 2009 Red Hat, Inc.
         License: GPL
         Author: Jeff Fearn <jfearn at redhat.com>
         Author: Tammy Fox <tfox at redhat.com>
         Author: Andy Fitzsimon <afitzsim at redhat.com>
         Author: Paul Morgan <pmorgan at redhat.com>
-->

<!DOCTYPE xsl:stylesheet [
<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
  ]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version='1.0'
                 xmlns="http://www.w3.org/TR/xhtml1/transitional"
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
                 exclude-result-prefixes="#default">

<xsl:import 
href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
<xsl:import 
href="http://docbook.sourceforge.net/release/xsl/current/fo/graphics.xsl"/>
<xsl:import 
href="http://docbook.sourceforge.net/release/xsl/current/fo/titlepage.templates.xsl"/>
<xsl:import href="../../../xsl/defaults.xsl"/>
<xsl:import href="../../../xsl/pdf.xsl"/>

<xsl:variable name="classification">
<xsl:choose>
<xsl:when test="//book[1]/@security">
<xsl:value-of select="//book[1]/@security"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>NOT CLASSIFIED</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<!-- running header -->
<xsl:param name="header.rule" select="0"/>
<xsl:template name="header.content">
<xsl:param name="position" select="''"/>
<xsl:param name="pageclass" select="''"/>
<xsl:choose>
<xsl:when test="$position='center'">
<fo:block-container
       absolute-position="absolute"
 >
<fo:block keep-together.within-line="always" font-weight="bold" 
color="black" font-size="14pt" text-align="center">
<xsl:value-of select="$classification"/>
</fo:block>
</fo:block-container>
</xsl:when>
</xsl:choose>
</xsl:template>

<!-- running footer -->
<xsl:template name="footer.content">
<xsl:param name="position" select="''"/>
<xsl:param name="pageclass" select="''"/>
<xsl:param name="sequence" select="''"/>
<xsl:choose>
<xsl:when test="$position='center'">
<fo:block-container
       absolute-position="absolute"
       top="0pt"
 >
<fo:block text-align="center">Page <fo:page-number/></fo:block>
<fo:block keep-together.within-line="always" font-weight="bold" 
color="black" font-size="14pt" text-align="center">
<xsl:value-of select="$classification"/>
</fo:block>
</fo:block-container>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

<!-- running footer -->
<xsl:template name="footer.content">
<xsl:param name="position" select="''"/>
<xsl:param name="pageclass" select="''"/>
<xsl:param name="sequence" select="''"/>
<xsl:choose>
<xsl:when test="$position='center'">
<fo:block-container
       absolute-position="absolute"
       top="0pt"
 >
<fo:block text-align="center">Page <fo:page-number/></fo:block>
<fo:block keep-together.within-line="always" font-weight="bold" 
color="black" font-size="14pt" text-align="center">
<xsl:value-of select="$classification"/>
</fo:block>
</fo:block-container>
</xsl:when>
<xsl:when test="$pageclass = 'titlepage' and $position = 'center'">
<fo:block-container
       absolute-position="absolute"
 >
<fo:block keep-together.within-line="always" font-weight="bold" 
color="black" font-size="14pt" text-align="center">
<xsl:value-of select="$classification"/>
</fo:block>
</fo:block-container>
</xsl:when>
<xsl:when test="$sequence = 'first' and $position = 'center'">
<fo:block-container
       absolute-position="absolute"
 >
<fo:block keep-together.within-line="always" font-weight="bold" 
color="black" font-size="14pt" text-align="center">
<xsl:value-of select="$classification"/>
</fo:block>
</fo:block-container>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>


-- 
A: No.
Q: Should I include quotations after my reply?

Don't top post: see http://www.caliburn.nl/topposting.html for more.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2687 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/publican-list/attachments/20091209/33025c63/attachment.p7s>


More information about the publican-list mailing list