Lines are visible only on the 1st page - jasper-reports

Here is my detail band:
<detail>
<band height="20" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[$V{antibioResult}]]></printWhenExpression>
<subreport>
<reportElement mode="Opaque" x="1" y="1" width="798" height="19" forecolor="#172983" uuid="d6dabfde-0ea9-4b6b-83c4-b557815cedee">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<subreportParameter name="binary_id">
<subreportParameterExpression><![CDATA[$P{binary_id}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA["bacreport.jasper"]]></subreportExpression>
</subreport>
<line>
<reportElement style="borderLine" stretchType="ContainerHeight" mode="Opaque" x="0" y="0" width="1" height="20" uuid="d5cb2ecc-f71a-4a3c-8d27-7be4c5a86da5">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
</line>
<line>
<reportElement style="borderLine" stretchType="ContainerHeight" x="800" y="0" width="1" height="20" uuid="08e46ff8-8a65-406b-9164-a6737baa022e">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
</line>
</band>
</detail>
And here is BorderLine style:
<style name="borderLine" forecolor="#172983"/>
Two lines are visible only in 1st page and not visible in others.
How to fix that?
UPD: It's looks like the lines is not drawn after page break. So how to stretch those line to the whole subreport to several pages?

Found a solution: set "Details Overflows" flag to the Line element.

Related

How shrink a frame when the bottom frames inside are blank.?

So im trying shrink the right frame when the last two inside frames containing the
text fields(red boxes) are blank. The left and right main frames are also inside a frame. But even if only have 4 rows i always get the unused space in the report.
<detail>
<band height="11" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[$V{REPORT_COUNT}>1]]></printWhenExpression>
</band>
<band height="71" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="554" height="71" isRemoveLineWhenBlank="true" uuid="603f6666-1471-4d16-b0aa-bde352f18b8e">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<frame>
<reportElement style="Default" stretchType="RelativeToTallestObject" x="0" y="0" width="301" height="50" isRemoveLineWhenBlank="true" uuid="a12bdb49-abd3-4ecf-83db-033e5846174d"/>
<frame>
<reportElement positionType="Float" x="0" y="20" width="300" height="10" isRemoveLineWhenBlank="true" uuid="ec17f3b3-e6e1-4f57-89e1-3499e4aa63cb">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!(EXACT(continitions]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" uuid="96082d63-b65e-4461-951d-6f6532ca9fe0">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["Morada"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" uuid="227f2a1f-3fc6-4fbf-a680-6d4ec4bbf86b"/>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[(condditions]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="30" width="300" height="10" isRemoveLineWhenBlank="true" uuid="115c7def-a074-4164-8738-649cecaa095a">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[conditions]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" uuid="d46cb243-e8e7-4775-9abb-c8600e44f884">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field_label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="" x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" uuid="c9f0f6dc-9fc3-49bd-ac4c-7de41ac07633"/>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[conditions]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="10" width="300" height="10" isRemoveLineWhenBlank="true" uuid="016e4775-e417-4f5c-a4de-b0be970e9d3a">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" uuid="e4e78c67-a0c0-4d01-9942-3429ce402bc5">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$(field)]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" uuid="6b3ac9a8-28a5-413e-9348-e9625f94c235">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement x="0" y="0" width="300" height="10" isRemoveLineWhenBlank="true" uuid="7f7b2531-9450-4a9f-b311-625df5ccae4f">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" isRemoveLineWhenBlank="true" uuid="c5a3d310-c74f-4546-97b0-18aa4de9a45a">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="649b1963-912c-4902-8052-1320e32e67ab">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
</frame>
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="301" y="0" width="244" height="70" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="c1a1530c-2fca-43d8-a238-f48f3290da29">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<frame>
<reportElement positionType="Float" x="0" y="40" width="244" height="10" isRemoveLineWhenBlank="true" uuid="a96e6e9f-e02f-4e9b-a900-2e55a33df0f3">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition)))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="edb4759b-cf68-4367-8bc4-7e07364ae3c5">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field_label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" isPrintWhenDetailOverflows="true" uuid="48766f62-03de-407a-a771-6e82e5a4c7ff">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="10" width="244" height="10" isRemoveLineWhenBlank="true" uuid="acbe8ba0-af8d-4e1a-93a8-7305a02839a6">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition)))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="d14807d2-aa00-421f-9dab-7cce0adf758a">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="63e62a4d-9dca-4dca-85f5-515a4ee18d0b">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{locationscope_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="0" width="244" height="10" isRemoveLineWhenBlank="true" uuid="cc62c22d-cc19-4461-ba53-74f4ba733322">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition})))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="6ce16cc5-2a18-4b3d-a7f7-17979a0a111b">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="cc7b895b-2e4f-4118-830f-1bde2e181be6">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{scope_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="30" width="244" height="10" isRemoveLineWhenBlank="true" uuid="4c9ae6a0-6534-4952-be6c-7a18d8351a3c">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition})))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="1c8aedb1-020b-4d7f-aea2-93b0557b2c23">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="c7ae3de9-2f2d-4178-85b2-bf2091766558">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="20" width="244" height="10" isRemoveLineWhenBlank="true" uuid="8f058c9f-27d5-4f0f-8eac-32a58fa7ad06">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition})]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="ba3f46e3-c823-4815-a74d-7a4caa77828f">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="75cce569-0fc5-425b-a9fc-9a42516a4305">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="50" width="244" height="10" isRemoveLineWhenBlank="true" uuid="18fad1eb-f42f-4876-be03-40aac2765875">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<printWhenExpression><![CDATA[!($F{condition}]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="2e21f092-a95f-42b1-897e-50af56985554">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="a9fe6852-4253-4fb9-a089-d007459655dd">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="60" width="244" height="10" isRemoveLineWhenBlank="true" uuid="c102458f-d273-4611-a851-ed8e83adfead">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<printWhenExpression><![CDATA[!($F{condntion})]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="80dcd916-f4c8-434d-a833-e864f64ddae5">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field_label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="5676615c-3ae5-41c6-8cf1-dbdef5cc3a99">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
</frame>
</frame>
</band>
</detail>
In jasper reports you can not shrink elements, instead you need to stretch them when needed.
In your case this means that your frames in report needs to be at the minimum size you need, then if there is more content in them you stretch it.
For example, your first frame
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="554" height="71" isRemoveLineWhenBlank="true" uuid="603f6666-1471-4d16-b0aa-bde352f18b8e">
......
it will always have a minimum height of 71, if it it needs to be smaller (when some components are not displayed) you need to reduce this value to for example 10.
To explain this behavior, I will attach a small example, with a frame (that has a border) that contains 2 static text fields and the second one will display based on a parameter.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_3" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="53801704-697f-43ac-aed6-9e952be4ab7f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="ShowText2" class="java.lang.Boolean">
<defaultValueExpression><![CDATA[true]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="96" splitType="Stretch">
<frame>
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="545" height="30" uuid="6ca5ba0c-b9c0-4ae9-be7f-e7a372593e94"/>
<box>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="7291cb69-0d98-4ce2-8031-60b5c6df4ebb"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Static text 1]]></text>
</staticText>
<staticText>
<reportElement x="0" y="30" width="100" height="30" isRemoveLineWhenBlank="true" uuid="7df247c0-2c72-4413-83f5-3d4d3aec258c">
<printWhenExpression><![CDATA[$P{ShowText2}]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Static text 2]]></text>
</staticText>
</frame>
</band>
</title>
</jasperReport>
Output
Not displaying second text field
Displaying second text field
The key concept is that the frame has height="30" which is the not stretched value (minimum value) and instead it gets stretched to height="60" if the second text field is displayed.
Note: I'm using stretchType="ElementGroupHeight" since stretchType="RelativeToTallestObject" is deprecated.

How on frame keep same behavior when printWhenExpression is false as if it does not exists?

So I have a detail band with two frames, the first frame has several elements including a subreport, the second frame only has a textfield.
The issue I'm having is, if i remove the second frame from the band all the content remains in the same page. If i add the second frame and use the printonly expression to not show it, it changes the entire content to the next page.
Is there a way to force that, if the second frame is empty to maintain the behavior as if didn't exist at all?
<band height="160" splitType="Prevent">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<frame>
<reportElement isPrintRepeatedValues="false" x="0" y="1" width="556" height="116" isRemoveLineWhenBlank="true" uuid="3aca49ee-4b55-452c-a8c6-5cc252c4175c">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<subreport>
<reportElement positionType="Float" x="2" y="65" width="160" height="51" uuid="438d3f08-7b8a-4b61-b17f-19993aa5abe4">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
</reportElement>
<subreportParameter name="DOC_ID">
<subreportParameterExpression><![CDATA[$P{DOC_ID}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="IS_RUNNING_LOCAL">
<subreportParameterExpression><![CDATA[$P{IS_RUNNING_LOCAL}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{IS_RUNNING_LOCAL} ? "/Reports/Common/xxxxxxxxxxxxxxSub.jasper" : "repo:/Reports/Common/xxxxxxxxxxxxxxSub"]]></subreportExpression>
</subreport>
<textField isStretchWithOverflow="true">
<reportElement style="Default" positionType="Float" mode="Transparent" x="1" y="1" width="552" height="30" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="837c85bf-7a2a-4eb5-919d-bd16d4bc64f2">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
<property name="local_mesure_unitheight" value="pixel"/>
</reportElement>
<box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
<textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
<font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
</textElement>
<textFieldExpression><![CDATA["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Default" positionType="Float" mode="Transparent" x="2" y="43" width="511" height="17" forecolor="#000000" backcolor="#FFFFFF" uuid="3e1c3952-6578-4d5f-85a3-d706fc5a5fbb">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="cm"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
<property name="local_mesure_unitheight" value="pixel"/>
</reportElement>
<box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
<textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
<font fontName="Arial" size="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
</textElement>
<textFieldExpression><![CDATA["testetestestestestestes"]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="1" y="120" width="555" height="40" isRemoveLineWhenBlank="true" uuid="c3bf96ce-dd19-41f1-bf13-fe1dd46d8d4e">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
</reportElement>
<textField isBlankWhenNull="true">
<reportElement positionType="Float" isPrintRepeatedValues="false" mode="Transparent" x="1" y="0" width="551" height="39" isRemoveLineWhenBlank="true" uuid="c1ab35b8-31a6-41e9-a260-71bbcab8692e">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Justified">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA["PS: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
</textField>
</frame>
</band>
Is there a way to force that, if the second frame is empty to maintain the behavior as if didn't exist at all?
The solution to this is to use multiple detail bands and set the printWhenExpression to the detail band
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TestParams" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f85bc6aa-5060-4485-bd99-bd5de1734ef1">
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="116">
<break>
<reportElement x="0" y="5" width="100" height="1" uuid="fb9c89cd-1b6a-44f5-82a9-99e9996229e3">
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
</reportElement>
</break>
<frame>
<reportElement x="0" y="10" width="200" height="116" uuid="e6890adf-6ff1-49f6-9c47-ba6f171a2c60"/>
</frame>
</band>
<band height="40">
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
<frame>
<reportElement x="0" y="0" width="200" height="40" uuid="d9f8ba4a-e435-49ff-9ff7-d23e55aecc52"/>
</frame>
</band>
</detail>
</jasperReport>
This way if second component is not showing/printed the whole band (height) will be removed and it will behave as only first band exists.

How to set stacked bar chart graph "Fit to page size" report using Jaspersoft studio?

How to set stacked bar chart graph "Fit to page size" (the graph should cover the whole page and stretch according to data without overlapping) in jasper report using Jaspersoft studio ?
I have taken "Chart_elememt" inside "Frame_element". I have tried changing the appearance properties of Chart_element and Frame_element but none of them worked.
Basically, I had two graphs in one .jrxml which created the problem of x-y axis (was not able to start both the graphs by "0" x-axis i.e. from bottom of my page), so I created sub-report and moved the second graph into it. Now my first graph is working fine, but second graph (in sub-report) is still reflecting shrinked and overlapping data though I have kept same properties as I have for my first graph.
In sub-report - Shrinked Graph (Data overlapping and is not Fit-to-page)
In main report - Expected Graph
Main report source code where subreport is called:
<subreport>
<reportElement stretchType="RelativeToTallestObject" x="0" y="1002" width="1088" height="20">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<subreportParameter name="start">
<subreportParameterExpression><![CDATA[$P{start}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="end">
<subreportParameterExpression><![CDATA[$P{end}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["QuantitéRelancesCause_subreport.jasper"]]></subreportExpression>
</subreport>
Subreport source code:
<title>
<band height="1051">
<staticText>
<reportElement mode="Transparent" x="410" y="10" width="250" height="40">
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font size="20"/>
<paragraph lineSpacing="Single"/>
</textElement>
<text><![CDATA[Quantité relances/cause]]></text>
</staticText>
<frame>
<reportElement positionType="FixRelativeToBottom" stretchType="RelativeToBandHeight" mode="Transparent" x="0" y="80" width="1090" height="904" isRemoveLineWhenBlank="true">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<stackedBarChart>
<chart isShowLegend="false" evaluationTime="Report">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Transparent" x="0" y="80" width="1080" height="824">
<property name="net.sf.jasperreports.chart.range.axis.tick.interval" value="1"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$F{DESCRIPTION}]]></seriesExpression>
<categoryExpression><![CDATA[$F{DESCRIPTION}]]></categoryExpression>
<valueExpression><![CDATA[$F{COUNT(DISTINCT(PIECE_ID))}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot isShowLabels="true" isShowTickLabels="true" isShowTickMarks="true">
<plot labelRotation="-45.0"/>
<itemLabel/>
<categoryAxisFormat labelRotation="-45.0">
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</barPlot>
</stackedBarChart>
</frame>
</band>
</title>

Shift the complete content to next page if it is not getting adjusted in previous page

I have a scenario where I have to shift the complete content to next page if it is not getting adjusted to previous page. Currently the content getting broken up between pages. I tried to put the contents inside the frame element but didn't work.
Screenshot:
And Here is the jrxml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.0.final using JasperReports Library version 6.3.0 -->
<!-- 2017-08-10T12:25:01 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="note11-pledgedassets" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="0" uuid="eff89e48-1135-41dd-b056-b42855f2ba3d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<style name="style2">
<conditionalStyle>
<conditionExpression><![CDATA[$F{label}.equals("Summa ställda säkerheter :")]]></conditionExpression>
<style fontName="SegoeUI" isItalic="true"/>
</conditionalStyle>
</style>
<queryString>
<![CDATA[]]>
</queryString>
<field name="label" class="java.lang.String"/>
<field name="amount" class="java.lang.String"/>
<field name="count" class="java.lang.Integer"/>
<field name="number" class="java.lang.Integer"/>
<field name="financialYearEndDate" class="java.lang.String"/>
<field name="text" class="java.lang.String"/>
<detail>
<band height="90" splitType="Prevent">
<frame>
<reportElement positionType="Float" x="21" y="1" width="530" height="89" isRemoveLineWhenBlank="true" uuid="c171bfff-1a99-40f3-a010-9429cae01a9c">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
</reportElement>
<box>
<topPen lineWidth="3.0" lineStyle="Solid"/>
<leftPen lineWidth="3.0" lineStyle="Solid"/>
<bottomPen lineWidth="3.0" lineStyle="Solid"/>
<rightPen lineWidth="3.0" lineStyle="Solid"/>
</box>
<textField isBlankWhenNull="true">
<reportElement style="style2" positionType="Float" x="1" y="28" width="364" height="15" isRemoveLineWhenBlank="true" uuid="693a615c-58a8-4b74-859f-31da16548c0f">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<printWhenExpression><![CDATA[$F{amount}!=null && !$F{amount}.equals("0")]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Bottom">
<font fontName="SegoeUI" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="style2" positionType="Float" x="384" y="28" width="100" height="15" isRemoveLineWhenBlank="true" uuid="e1094881-70b8-47af-b7d4-a52b16285a12">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[$F{amount}!=null && !$F{amount}.equals("0")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font fontName="SegoeUI" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{amount}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="1" y="15" width="100" height="13" isRemoveLineWhenBlank="true" uuid="82c2a4cc-07ca-4252-99c9-a497c7664c23">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[$F{count}==1]]></printWhenExpression>
</reportElement>
<text><![CDATA[]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="1" y="43" width="270" height="31" isRemoveLineWhenBlank="true" uuid="c0fac058-23f1-47e2-a57b-f8d8111437d6">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[$F{text}!=null]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Bottom">
<font fontName="SegoeUI" size="9" isItalic="true"/>
</textElement>
<text><![CDATA[Säkerheter till förmål för styrelse, vd mfl]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement positionType="Float" x="1" y="74" width="474" height="15" isRemoveLineWhenBlank="true" uuid="385ae7d5-4c0e-437e-b04c-64f925c275df">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<printWhenExpression><![CDATA[$F{text}!=null]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Bottom">
<font fontName="SegoeUI" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
</textField>
<frame>
<reportElement mode="Opaque" x="0" y="1" width="490" height="14" isRemoveLineWhenBlank="true" backcolor="#CCCCCC" uuid="2dd91d48-f783-422b-9a4c-956f93f62590">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<printWhenExpression><![CDATA[$F{count}==1]]></printWhenExpression>
</reportElement>
</frame>
<staticText>
<reportElement mode="Opaque" x="2" y="1" width="40" height="14" isRemoveLineWhenBlank="true" backcolor="#CCCCCC" uuid="d25eb93c-cf83-449b-8a64-b08b3662dfb7">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<printWhenExpression><![CDATA[$F{count}==1]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="SegoeUI-SemiBold" size="9"/>
</textElement>
<text><![CDATA[Not]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement mode="Opaque" x="384" y="1" width="100" height="14" isRemoveLineWhenBlank="true" backcolor="#CCCCCC" uuid="442d41c6-ab53-4af4-a17c-e48f27a60bba">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<printWhenExpression><![CDATA[$F{count}==1]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SegoeUI-SemiBold" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{financialYearEndDate}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement mode="Opaque" x="29" y="1" width="40" height="14" isRemoveLineWhenBlank="true" backcolor="#CCCCCC" uuid="1b39f3a4-56a6-4b41-af03-01dbed404c68">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<printWhenExpression><![CDATA[$F{count}==1]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="SegoeUI-SemiBold" size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{number}]]></textFieldExpression>
</textField>
<staticText>
<reportElement mode="Opaque" x="69" y="1" width="296" height="14" isRemoveLineWhenBlank="true" backcolor="#CCCCCC" uuid="8c1f2b48-7417-494b-9143-08145e05939f">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<printWhenExpression><![CDATA[$F{count}==1]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="SegoeUI-SemiBold" size="9"/>
</textElement>
<text><![CDATA[Ställda säkerheter]]></text>
</staticText>
</frame>
</band>
</detail>
</jasperReport>
Put that particual content in separate details section and set the split type as prevent for that detail section.

How to add table of content in Jasper report

I am using JasperSoft Studio. I am generating a report which having Chapter and sub-chapter also. but all these Chapter and Sub-Chapter configured in Sub-report.
How I can get all these Chapter and Sub-chapter name with link, page number in a table of content formatted in one page like a standard table of content of a document?
EDIT: Moved users answer to question (it should be an edit of the question)
Bookmarks are coming in jasperserver (in separate tab ) but not coming in report. In TOC all the field evaluationTime=report. Here is my TOC jrxml code .
<detail>
<band height="25" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[$F{level} == 1]]></printWhenExpression>
<textField evaluationTime="Report" hyperlinkType="LocalAnchor">
<reportElement style="HeadingLabel1" x="0" y="5" width="470" height="20" uuid="379fcff2-021d-4761-a89a-eeb772723b1b">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
<textField evaluationTime="Auto" hyperlinkType="LocalAnchor">
<reportElement style="HeadingIndex1" x="470" y="5" width="45" height="20" uuid="a31e80f3-f1fa-4643-adbe-77a61c7b9051">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Bottom"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 1]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
</band>
<band height="25" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[$F{level} == 2]]></printWhenExpression>
<textField evaluationTime="Report" hyperlinkType="LocalAnchor">
<reportElement style="HeadingLabel2" x="40" y="5" width="430" height="20" uuid="379fcff2-021d-4761-a89a-eeb772723b1b">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
<textField evaluationTime="Auto" hyperlinkType="LocalAnchor">
<reportElement style="HeadingIndex2" x="470" y="5" width="45" height="20" uuid="a31e80f3-f1fa-4643-adbe-77a61c7b9051">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Bottom"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 1]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
<textField evaluationTime="Report" hyperlinkType="LocalAnchor">
<reportElement style="HeadingLabel2" x="20" y="5" width="20" height="20" uuid="ae12cafd-22e8-45ae-a1a7-8e00a8208cf0">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$V{level2Index} + "."]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
</band>
<band height="15" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[$F{level} == 3]]></printWhenExpression>
<textField evaluationTime="Report" hyperlinkType="LocalAnchor">
<reportElement style="HeadingLabel3" x="40" y="0" width="430" height="15" uuid="379fcff2-021d-4761-a89a-eeb772723b1b">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
<textField evaluationTime="Auto" hyperlinkType="LocalAnchor">
<reportElement style="HeadingIndex3" x="470" y="0" width="45" height="15" uuid="a31e80f3-f1fa-4643-adbe-77a61c7b9051">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Bottom"/>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 1]]></textFieldExpression>
<hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
</textField>
</band>
</detail>
EDIT: here is my main report jrxml.
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="TCD"/>
<property name="net.sf.jasperreports.print.create.bookmarks" value="true"/>
<property name="com.jaspersoft.studio.book.group.cover.header" value="Cover and Table of Contents"/>
<property name="com.jaspersoft.studio.book.group.cover.footer" value="Backcover"/>
<property name="ireport.jasperserver.url" value="http://localhost:8080/jasperserver/"/>
<property name="ireport.jasperserver.user" value="jasperadmin"/>
<property name="ireport.jasperserver.report.resource" value="/reports/TCD_book_page_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/reports/TCD_book_page"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[SELECT 1 NO FROM DUAL]]>
</queryString>
<field name="NO" class="java.lang.Integer"/>
<group name="cover">
<groupHeader>
<part evaluationTime="Report" uuid="56ab525c-754f-4f48-a52c-7cc23934be3d">
<property name="net.sf.jasperreports.bookmarks.data.source.parameter" value="REPORT_DATA_SOURCE"/>
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportExpression><![CDATA["TCD_book_page_toc.jasper"]]></subreportExpression>
</p:subreportPart>
</part>
</groupHeader>
</group>
<detail>
<part uuid="5196d1c8-d060-450f-b9f5-9089918b7389">
<p:subreportPart xmlns:p="http://jasperreports.sourceforge.net/jasperreports/parts" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/parts http://jasperreports.sourceforge.net/xsd/parts.xsd">
<subreportParameter name="REPORT_CONNECTION">
<subreportParameterExpression><![CDATA[$P{REPORT_CONNECTION}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA["TCD_Page.jrxml"]]></subreportExpression>
</p:subreportPart>
</part>
</detail>
The http://jasperreports.sourceforge.net/sample.reference/tableofcontents/ does work even if you have the bookmarks in your subreport's. (in example they are in subreport).
Some important notice:
The main report should have the net.sf.jasperreports.print.create.bookmarks set in order to collect bookmarks at report generation time.
The Table of Contents part needs to be evaluated after other report
parts; if the part is to be printed at the beginning of the document
it should have Report evaluation (and no subsequent parts should have
the same evaluation).
If you do not want to use this feature of jasper report, you need to generate your own scriplet to collect data see for example:
how-can-i-build-a-table-of-contents-in-ireport-jasperreports