I have a big report that consists solely of a looped set of nested subreports.
Essentially it can be thought of as a list of subreports which I generate in a loop and embed in the main report vertically. The main report just a header and footer and the subreport has no header or footer.
When my loop creates about 20 or less subreports, all is fine and the main report builds. If a subreport is embedded near the end of a page then it breaks the subreport across two pages.
Hiowever, once I go above about 20 subreports I get the error
net.sf.dynamicreports.report.exception.DRException: net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. The summary section and the margins do not fit the page height.
Each subreport is roughly the same vertical height, so I’m a bit confused as to why this happens. I’m quite positive there isn’t suddenly a long subreport that triggers this error.
I would expect it to keep adding more subreports and simply produce more pages.
I have tried turning on these 2 flags but this makes no difference.
reportBuild.setSummaryWithPageHeaderAndFooter(true);
reportBuild.setTitleOnANewPage(true);
Any ideas?
I have managed to solve this issue and am posting it here for others. I followed this question
[/questions/16670097/creating-a-dynamic-report-without-data-source-and-putting-data-in-detail-band-al]
Basically, you need to create an empty data source for the detail section and then add all the subreports to a multipage list builder, add the multilist to the detail section and then build the main report and export to pdf, by doing this
JasperReportBuilder reportBuild = DynamicReports.report();
reportBuild.setPageFormat(PageType.A4, PageOrientation.PORTRAIT);
MultiPageListBuilder multipage = cmp.multiPageList();
reportBuild.setDataSource(new net.sf.jasperreports.engine.JREmptyDataSource());
…
String sWONo = rsltset.getString("WEDNo");
String sPWPNo = rsltset.getString("PWPNo");
String sPMANo = rsltset.getString("PMANo");
subReports[i] = cmp.subreport(getImageSubReport(sWONo, sPWPNo,sPMANo));
subReports2[i] = cmp.subreport(getCommonSubReport(sWONo, sPWPNo,sPMANo));
multipage.add(cmp.verticalList(subReportBody2));
multipage.add(cmp.verticalList(subReports2[i]));
multipage.add(cmp.verticalGap(20));
multipage.add(subReports[i]);
multipage.add(cmp.verticalGap(20));
}
reportBuild.addDetail(multipage);
reportBuild.summaryWithPageHeaderAndFooter();
reportBuild.toPdf(export.pdfExporter(sRandomFile));