Java: blank page issue on jasper report

jasper-reportsjava

I have a report that has 2 sub reports in the detail band.I would like to add in a paging parameter in the column footer but when I preview my report it gives me a blank page at the end. I have set the following for my Sub Report block in the their property window.

Print Repeated Values checked

Remove Line When Blank checked

Best Solution

With the usage of this link http://mattjiang.blogspot.com/2007/05/easy-way-to-remove-blank-page-generated.html, I could navigate through the generated jasper and I found "trash elements" in my report:

int actualPage = 1;
for (Iterator<JRPrintPage> i=jasperPrint.getPages().iterator(); i.hasNext();) {
  JRPrintPage page = i.next();
  System.out.println(String.format("Page: %s, size: %s", actualPage, page.getElements().size()));
     for (Object element : page.getElements()) {
        System.out.println("Element: " + element);
        if (element instanceof JRTemplatePrintRectangle) {
            JRTemplatePrintRectangle rectangle = (JRTemplatePrintRectangle) element;
            System.out.println(String.format("Rectangle: Key: %s", rectangle.getKey()));
        }
    }
     actualPage++;
}