I'm using Jasper Reports 3.7.2. I have a report with two columns, set to horizontal print order, a summary band, and using an XML datasource. Whenever the printing stops with all columns having the exact same amount of records (in my case an even amount of records), the summary band is always pushed to the next page. Why does this happen? It almost has to a be a bug…
If you switch the print order to vertical the problem goes away. I can find no explanation as to why the horizontal print order causes the summary to go to the next page. I also noticed this problem occurs on version "4.1". Here is an example of simple report that shows the problem:
<?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="horizontal-issue" columnCount="2" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[select * from
(select 'hello' as hello) AS hello
union all
select * from
(select 'hello' as hello) AS hello
union all
select * from
(select 'hello' as hello) AS hello
union all
select * from
(select 'hello' as hello) AS hello]]>
</queryString>
<field name="hello" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band splitType="Stretch"/>
</title>
<pageHeader>
<band splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="129" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{hello}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band splitType="Stretch"/>
</pageFooter>
<summary>
<band height="33" splitType="Stretch">
<staticText>
<reportElement x="239" y="7" width="100" height="20"/>
<textElement>
<font size="16"/>
</textElement>
<text><![CDATA[SUMMARY]]></text>
</staticText>
</band>
</summary>
</jasperReport>
Best Answer
I had the same problem and it still seems to be unsolved.
My solution is just a workaround, but it works:
Example: