I am trying to create my table of contents in jasper studio 6.4.3. It has to be a dotted TOC, which means I need to fill the space between label text field and page number text filed with dots. The solution that I have at the time has two problems.
First: There are half dots to see, depending the length of the texts in fields
Second: I can not get the dots and page number field aligned to the label after stretch. The solution for the dots is, having a static text field behind both text fields and set the text fields background to with, in order to cover the dots behind the texts.

<band height="31" splitType="Stretch">
        <property name="local_mesure_unitheight" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
        <printWhenExpression><![CDATA[$F{level} == 1]]></printWhenExpression>
        <staticText>
            <reportElement style="InhaltsverzeichnisPunkte" mode="Transparent" x="0" y="1" width="440" height="18" uuid="b08b479c-10a8-4d87-8507-4f32fd50004f"/>
            <text><![CDATA[. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .]]></text>
        </staticText>
        <textField isStretchWithOverflow="true">
            <reportElement style="InhaltsverzeichnisPunkte" x="396" y="1" width="45" height="18" uuid="bc43bd36-7466-457c-95e6-384410c05cbe"/>
            <textElement textAlignment="Right"/>
            <textFieldExpression><![CDATA["<style backcolor='white'>"+($V{PAGE_NUMBER} + $F{pageIndex} + 3)+"</style>"]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
            <reportElement style="Formatvorlage Standard (kleiner) + 10 Pt." mode="Transparent" x="0" y="3" width="396" height="15" uuid="b19a02f7-3d3f-4086-86ed-5dc6859e5fd1"/>
            <textElement textAlignment="Left" markup="styled"/>
            <textFieldExpression><![CDATA["<style backcolor='white'>"+$F{label}+"</style>"]]></textFieldExpression>
            <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
        </textField>
    </band>
As you can see in the picture, the page number 6 need and the dots should be appear aligned to the second line in the text field, and the dot after character g is cut.
You can almost achieve what you want with:
verticalAlignment set to Bottom for all your text elementsstretchType set to ContainerBottom for the 'dotted' staticText and the 'page index' textField elementslike so:
<band height="39" splitType="Stretch">
<staticText>
    <reportElement stretchType="ContainerBottom" mode="Transparent" x="0" y="1" width="440" height="18" uuid="b08b479c-10a8-4d87-8507-4f32fd50004f"/>
    <textElement verticalAlignment="Bottom"/>
    <text><![CDATA[. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .]]></text>
</staticText>
<textField isStretchWithOverflow="true">
    <reportElement stretchType="ContainerBottom" x="396" y="1" width="45" height="18" uuid="bc43bd36-7466-457c-95e6-384410c05cbe"/>
    <textElement textAlignment="Right" verticalAlignment="Bottom" markup="styled"/>
    <textFieldExpression><![CDATA["<style backcolor='white'>"+($V{PAGE_NUMBER} + $F{pageIndex} + 3)+"</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
    <reportElement mode="Transparent" x="0" y="3" width="396" height="16" uuid="b19a02f7-3d3f-4086-86ed-5dc6859e5fd1">
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
    </reportElement>
    <textElement textAlignment="Left" verticalAlignment="Bottom" markup="styled"/>
    <textFieldExpression><![CDATA["<style backcolor='white'>"+$F{label}+"</style>"]]></textFieldExpression>
    <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
The output:

Note:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With