I use jasper studio 6.17 and jasper library 6.17 and I have too much unused white space at the end of every page. I placed a image down to show the problem. So after record 21 there is a lot of free space that could easily fit records 22,23 and 24 but the space is not used, these records are displayed directly on page 2.
This is the jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd -->
<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="results" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true">
<field name="text" class="java.lang.String"/>
<field name="image" class="java.awt.Image"/>
<detail>
<band height="130" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="595" height="29" isRemoveLineWhenBlank="true"/>
<box padding="0">
<pen lineWidth="1.25" lineStyle="Solid" lineColor="#030303"/>
</box>
<textElement>
<font fontName="DejaVu Sans" isBold="true"/>
<paragraph lineSpacingSize="0.0"/>
</textElement>
<textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
</textField>
<image>
<reportElement x="0" y="29" width="190" height="100" isRemoveLineWhenBlank="true"/>
<box>
<pen lineWidth="2.0" lineColor="#030303"/>
</box>
<imageExpression><![CDATA[$F{image}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
And this is the full java code:
public class JasperBAM {
public static void main(String[] args) {
try {
List<BAMResult> bhs = BAMResult.getBAMResults();
JasperPrint jasperPrint = JasperFillManager.fillReport("JasperReports/results.jasper", null, new JRBeanCollectionDataSource(bhs));
OutputStream outputStream = new FileOutputStream(new File("BAM.pdf"));
JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
} catch (Exception ex) {
Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public class BAMResult {
private String text;
private BufferedImage image;
public void settext(String text){this.text=text;}
public String gettext(){return text;}
public void setimage(){
try {
image=ImageIO.read(new File("image.png"));
} catch (IOException ex) {
Logger.getLogger(BAMResult.class.getName()).log(Level.SEVERE, null, ex);
}
}
public BufferedImage getimage() {
return image;
}
public static List<BAMResult> getBAMResults() {
try {
List<BAMResult> brs = new ArrayList<>();
for(int i=1; i<100; i++) {
BAMResult nt = new BAMResult();
nt.settext("record "+i);
if (i % 20==0){
nt.setimage();
}
brs.add(nt);
}
return brs;
} catch (Exception ex) {
Logger.getLogger(JasperBAM.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
}
UPDATE 1 I tried to set the the "split type" of the detail band to "Immediate" but the space still appears.
UPDATE 2 The problem is not related to the image field, I tried to put a text field in the place of the image and the problem is the same.
