jgraf
I'm new here

Inhaltsverzeichnis im PDF erstellen

Hallo,

ich habe folgendes Problem:

- es werden pro Produkt ein passendes PDF generiert -> funktioniert

- es werden für alle Produkte die Informationen in ein Gesamt-PDF generiert, also ein Katalog -> funktioniert.

Jetzt möchte ich ein Inhaltsverzeichnis vor dem Katalog einfügen, funktioniert leider nicht.

Hier mein Code in der Setenvorlage-PDF-Kanal:

<CMS_HEADER>

<CMS_BODY name="Content left" />

<CMS_BODY name="Content center" />

<CMS_BODY name="Content right" />

</CMS_HEADER>

$CMS_SET(#global.debugMode, true)$

<?xml version="1.0" encoding="$CMS_VALUE(#global.encoding)$"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">

    <fo:layout-master-set>

        <fo:simple-page-master master-name="A4"

            page-width="210mm"

            page-height="297mm"

            margin-left="22mm"

            margin-right="23mm"

            margin-top="0mm">       

            <fo:region-body margin-top="0mm" margin-bottom="0mm"/>

            <fo:region-after region-name="footer" extent="15mm"/>

        </fo:simple-page-master>

    </fo:layout-master-set>

<fo:page-sequence master-reference="A4">

  <!-- Page content goes here -->

        <fo:flow flow-name="xsl-region-body">

                    <fo:block font-family="Helvetica" font-size="10pt" keep-with-previous.within-page="always">

                <fo:block break-after="page" id="$CMS_VALUE(#global.node.getUid())$$CMS_IF(!#global.multiPageParams.data.isEmpty && #global.node.content2Params.getRecordCountPerPage()>0)$_$CMS_VALUE(#global.multiPageParams.data.get(#global.pageParams.index).getId())$$CMS_END_IF$">

                    <fo:block>

                        <fo:inline font-size="15pt" font-weight="bold" color="#CF6100">$CMS_IF(!pt_headline.isEmpty)$$CMS_VALUE(pt_headline.convert)$$CMS_END_IF$</fo:inline>

                    </fo:block>

                    <fo:block space-after="1mm">

                        <fo:inline font-size="11pt" color="#CF6100">$CMS_IF(!pt_subheadline.isEmpty)$$CMS_VALUE(pt_subheadline.convert)$$CMS_END_IF$</fo:inline>

                    </fo:block>

                    <fo:block space-after="3mm">

                        $CMS_IF(!pt_intro.isEmpty)$$CMS_VALUE(pt_intro)$$CMS_END_IF$

                    </fo:block>

                    $CMS_VALUE(#global.page.body("productdata"))$

                    <fo:block id="theEnd" />

                </fo:block>

            </fo:block>   

        </fo:flow>

</fo:page-sequence>

</fo:root>

Grüße

0 Kudos
5 Replies
feddersen
Community Manager

Könnten Sie etwas genauer beschreiben was nicht funktioniert?

0 Kudos

Hier noch einmal der jetzt aktuelle Code:

- es geht hiermit die Seitennummerierung und es wird auf einer Startseite 'Inhaltsverzeichnis' ausgegeben.

Nur was muss ich wo einfügen damit das Inhaltsverzeichnis generiert wird ? Ich habe keine Idee.

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">

    <fo:layout-master-set>

        <fo:simple-page-master master-name="A4"

            page-width="210mm"

            page-height="297mm"

            margin-left="22mm"

            margin-right="23mm"

            margin-top="0mm">       

            <fo:region-body margin-top="0mm" margin-bottom="0mm"/>

            <fo:region-after region-name="footer" extent="15mm"/>

        </fo:simple-page-master>

    </fo:layout-master-set>

<fo:page-sequence master-reference="A4">


    <fo:static-content flow-name="footer">

        <fo:block text-align-last="center">

            <fo:page-number/>

        </fo:block>

    </fo:static-content>

        <fo:flow flow-name="xsl-region-body">

        <fo:block font-family="Helvetica" color="#004080" font-size="16pt" language="DE" keep-with-next.within-page="always" space-before="12pt" space-before.conditionality="retain" space-after="3pt" space-after.conditionality="retain" font-weight="normal">

            <fo:inline font-size="16pt" font-weight="bold">

                 <fo:leader leader-length="0pt"/>

Produktkatalog

             </fo:inline>

        </fo:block>

        <fo:block font-family="Helvetica" color="#004080"  font-size="10pt" language="DE">

            <fo:inline font-family="Helvetica" color="#004080"  font-size="10pt" font-weight="bold">

                 <fo:leader leader-length="0pt"/>

Inhaltsverzeichnis

             </fo:inline>

        </fo:block>

            <fo:block font-family="Helvetica" font-size="10pt" keep-with-previous.within-page="always">

                <fo:block break-after="page" id="$CMS_VALUE(#global.node.getUid())$$CMS_IF(!#global.multiPageParams.data.isEmpty && #global.node.content2Params.getRecordCountPerPage()>0)$_$CMS_VALUE(#global.multiPageParams.data.get(#global.pageParams.index).getId())$$CMS_END_IF$">

                    <fo:block>

                        <fo:inline font-size="15pt" font-weight="bold" color="#CF6100">$CMS_IF(!pt_headline.isEmpty)$$CMS_VALUE(pt_headline.convert)$$CMS_END_IF$</fo:inline>

                    </fo:block>

                    <fo:block space-after="1mm">

                        <fo:inline font-size="11pt" color="#CF6100">$CMS_IF(!pt_subheadline.isEmpty)$$CMS_VALUE(pt_subheadline.convert)$$CMS_END_IF$</fo:inline>

                    </fo:block>

                    <fo:block space-after="3mm">

                        $CMS_IF(!pt_intro.isEmpty)$$CMS_VALUE(pt_intro)$$CMS_END_IF$

                    </fo:block>

                    $CMS_VALUE(#global.page.body("productdata"))$

                    <fo:block id="theEnd" />

                </fo:block>

            </fo:block>   

        </fo:flow>

</fo:page-sequence>

</fo:root>

0 Kudos

Ein Inhaltsverzeichnis kann doch nur von einem selbsterstellten Script generiert werden,

welches über alle Seiten der Dokumentengruppe läuft.

0 Kudos

Nein, laut Doku geht das so (siehe unten) und muss in die fo:flow - Region.

Aber da geht schon das 'xsl:for-each' nicht und gilt als unbekannt.

Und wie setze ich im Template die 'book/chapter' - Markierung ?

Die '$Schriftgroesse' usw. sind nur Platzhalter und tun nichts zur Sache.


<xsl:template name="IVZ">

    <xsl:variable name="Ebene" select="count(ancestor-or-self::chapter | ancestor-or-self::section)"/>

    <xsl:choose>

        <xsl:when test="$Ebene = 1">

            <fo:table width="100%" space-before="4mm" space-after="2mm">

                <fo:table-column column-width="10%"/>

                <fo:table-column column-width="85%"/>

                <fo:table-column column-width="5%"/>

                <fo:table-body>

                    <fo:table-row>

                        <fo:table-cell>

                            <fo:block font-weight="bold">

                                <xsl:number count="chapter" format="1"/>

                            </fo:block>

                        </fo:table-cell>

                        <fo:table-cell>

                            <fo:block font-weight="bold" text-align-last="justify">

                                <fo:basic-link internal-destination="{generate-id()}">

                                    <xsl:apply-templates select="title" mode="ivz"/>

                                </fo:basic-link>

                                <xsl:text>&#x2004;</xsl:text>

                                <fo:inline font-weight="normal">

                                    <fo:leader leader-pattern="dots"/>

                                </fo:inline>

                            </fo:block>

                        </fo:table-cell>

                        <fo:table-cell display-align="after">

                            <fo:block font-weight="bold" text-align="right">

                                <fo:page-number-citation ref-id="{generate-id()}"/>

                            </fo:block>

                        </fo:table-cell>

                    </fo:table-row>

                </fo:table-body>

            </fo:table>

        </xsl:when>

        <xsl:when test="$Ebene = 2">

            <fo:table width="100%">

                <fo:table-column column-width="10%"/>

                <fo:table-column column-width="85%"/>

                <fo:table-column column-width="5%"/>

                <fo:table-body>

                    <fo:table-row>

                        <fo:table-cell>

                            <fo:block>

                                <xsl:number count="chapter" format="1."/>

                                <xsl:number count="section" format="1"/>

                            </fo:block>

                        </fo:table-cell>

                        <fo:table-cell>

                            <fo:block text-align-last="justify">

                                <fo:basic-link internal-destination="{generate-id()}">

                                    <xsl:apply-templates select="title" mode="ivz"/>

                                </fo:basic-link>

                                <xsl:text>&#x2004;</xsl:text>

                                <fo:leader leader-pattern="dots"/>

                            </fo:block>

                        </fo:table-cell>

                        <fo:table-cell display-align="after">

                            <fo:block text-align="right">

                                <fo:page-number-citation ref-id="{generate-id()}"/>

                            </fo:block>

                        </fo:table-cell>

                    </fo:table-row>

                </fo:table-body>

            </fo:table>

        </xsl:when>

    </xsl:choose>

</xsl:template>

<fo:flow flow-name="xsl-region-body">

    <fo:block font-family="{$Schriftname}" font-size="{$Schriftgroesse}" line-height="{$Zeilenhoehe}">

        <fo:block font-size="{$Schriftgroesse} * 1.4" line-height="{$Zeilenhoehe} * 1.3" font-weight="bold" space-after="18mm">

            Inhaltsverzeichnis

        </fo:block>

    </fo:block>

    <fo:block font-family="{$Schriftname}" font-size="{$Schriftgroesse}" line-height="{$Zeilenhoehe}">

        <xsl:for-each select="book/chapter | book/chapter/section">

            <xsl:call-template name="IVZ"/>

        </xsl:for-each>

    </fo:block>

</fo:flow>

0 Kudos

Hallo,

mir würde es schon helfen wenn ich wüsste wo ich

<xsl:template name="IVZ">

    <xsl:variable name="Ebene" select="count(ancestor-or-self::chapter | ancestor-or-self::section)"/>

                            <fo:block>

                                <xsl:number count="chapter" format="1."/>

                                <xsl:number count="section" format="1"/>

                            </fo:block>

   

</xsl:template>

einfügen muss damit es keine Fehlermeldung bei fo:block gibt.

0 Kudos