forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric BURGHARD <eburg...@free.fr>
Subject table of contents in pdf
Date Tue, 16 Sep 2003 10:11:38 GMT
Hi,

Don't know if this is interresting for someone down here, anyway it is 
valuable for me. this address two issues (from my point of view) of the 
document2fo.xsl stylesheet:
- generate table of contents
- correct font size computation for section/subsection/subsubsection

1- table of contents
Add this somewhere in your skin xslt/fo/document2fo.xsl after the
<xsl:import href="../../../common/xslt/fo/document2fo.xsl"/>
---
    <xsl:template match="body">
        <xsl:if test="count(//section) != 0">
            <fo:block font-family="serif" font-size="14pt" font-weight="bold" 
space-after="5pt" space-before="5pt" text-align="justify" width="7.5in"> 
<!-- insert i18n stuff here -->
Table of contents
 </fo:block>
            <fo:block font-family="sans" font-size="12pt" space-after="5pt" 
space-before="0pt" text-align="justify" width="7.5in">
                <xsl:apply-templates mode="toc"/>
            </fo:block>
        </xsl:if>
        <xsl:apply-templates/>
    </xsl:template>
    <!-- -->
    <xsl:template match="section" mode="toc">
        <fo:block space-before="5pt" text-align-last="justify">
            <fo:inline>
                <xsl:number count="section" format="1.1.1.1.1.1.1" 
level="multiple"/>
                <xsl:text>. </xsl:text>
                <xsl:value-of select="title"/>
                <fo:leader leader-pattern="dots"/>
                <fo:page-number-citation ref-id="{generate-id(  )}"/>
            </fo:inline>
            <xsl:apply-templates mode="toc2" select="section"/>
        </fo:block>
    </xsl:template>
    <!-- -->
    <xsl:template match="section" mode="toc2">
        <fo:block start-indent=".5em" text-align-last="justify" 
text-indent=".5em">
            <fo:inline padding-start="1em">
                <xsl:number count="section" format="1.1.1.1.1.1.1" 
level="multiple"/>
                <xsl:text>. </xsl:text>
                <xsl:value-of select="title"/>
                <fo:leader leader-pattern="dots"/>
                <fo:page-number-citation ref-id="{generate-id(  )}"/>
            </fo:inline>
        </fo:block>
    </xsl:template>
----

2- font size for section/subsection/subsubsection
in the <xsl:template match="section">, replace the <xsl:variable name="size">

block by this one:
----
    <xsl:variable name="size">
        <xsl:value-of select="14-number($level)"/>
    </xsl:variable>
----

A+


Mime
View raw message