Leader (e.g. in a TOC)

0

I like to beautify the Table of Contents which I created based on the sample given. In particular I would like the leaders - the (dotted) line up to the page number on the right - to fit the remaining(!) length of the line. Such features are for example available in the out of the box TOC templates of Microsoft Word. And to make things even more complex, ideally also handling multi-line scenarios (due to stretching). As you see in the included example I got to some point. VBut the dots are overlapping the text ... kind of obvious as I did place overlapping textFields. Is there a better way? And secondly tyou see in the last row with the very long text that the formatting is almost correct ... but why are the dots in the middle?

Table of Contents example

Of course, with the output goes some .jrmxl code so that you all can see what I've done:

 

<detail>
    <band height="15" splitType="Stretch">
        <printWhenExpression><![CDATA[$F{level} == 1]]></printWhenExpression>
        <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
            <reportElement style="Bold" x="40" y="0" width="460" height="15" isRemoveLineWhenBlank="true"/>
            <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
            <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
        </textField>
        <staticText>
            <reportElement style="Bold" positionType="FixRelativeToBottom" stretchType="ContainerBottom" x="150" y="0" width="375" height="15" isRemoveLineWhenBlank="true" />
            <textElement textAlignment="Right"/>
            <text><![CDATA[________________________________________________________________________________]]></text>
        </staticText>
        <textField isStretchWithOverflow="true" evaluationTime="Auto" hyperlinkType="LocalAnchor">
            <reportElement positionType="FixRelativeToBottom" stretchType="ContainerBottom" x="525" y="0" width="30" height="15" isRemoveLineWhenBlank="true" />
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 1]]></textFieldExpression>
            <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
        </textField>
    </band>
    <band height="15" splitType="Stretch">
        <printWhenExpression><![CDATA[$F{level} == 2]]></printWhenExpression>
        <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
            <reportElement positionType="Float" x="75" y="0" width="425" height="15" isRemoveLineWhenBlank="true"/>
            <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
            <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
            <hyperlinkTooltipExpression><![CDATA[$F{label}]]></hyperlinkTooltipExpression>
        </textField>
        <staticText>
            <reportElement positionType="FixRelativeToBottom" stretchType="ContainerBottom" x="150" y="0" width="375" height="15" isRemoveLineWhenBlank="true" uuid="c6cf49ba-d7d0-42fa-9b2c-36ba110e91f4"/>
            <textElement textAlignment="Right" verticalAlignment="Top"/>
            <text><![CDATA[.   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .   .]]></text>
        </staticText>
        <textField isStretchWithOverflow="true" evaluationTime="Auto" hyperlinkType="LocalAnchor">
            <reportElement positionType="FixRelativeToBottom" stretchType="ContainerBottom" x="525" y="0" width="30" height="15" isRemoveLineWhenBlank="true" "/>
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 1]]></textFieldExpression>
            <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
        </textField>
    </band>
</detail>

Any help would be greatly appreciated.

jan.cirpka's picture
Joined: Apr 19 2016 - 9:52am
Last seen: 1 week 11 hours ago

0 Answers:

No answers yet
Feedback