I am using JasperReportBuilder and exporting the report to PDF. The entire content of the report is generated by MultiPageListBuilder, HorizontalListBuilder and VerticalListBuilder and I don't want to pass the data source as data is coming from various data sources. I want to utilize page footer as well as page header for adding to static page header and footer on each page as well as page number. If I try to use addDetail(componentBuilder) method to add MultiPageListBuilder in *Detail& band (as this MultiPageListBuilder contains multiple page data), blank report generates. If I add MultiPageListBuilder in Title or Summary band, report generates perfectly but Page Header and Page Footer bands disappear.
A example code snippet is as follows
JasperReportBuilder rpt = net.sf.dynamicreports.report.builder.DynamicReports.report();
MultiPageListBuilder multiPageList = cmp.multiPageList();
HorizontalListBuilder hrbld = cmp.horizontalList();
try {
rpt.addTitle(cmp.text("REPORT TITLE"));
rpt.addTitle(cmp.text("--------------"));
rpt.addPageHeader(cmp.pageXofY());
for (int i = 0; i < 200; i++) {
hrbld = cmp.horizontalList();
hrbld.add(cmp.text("ABC " + i)).newRow();
multiPageList.add(hrbld);
}
rpt.addDetail(multiPageList);
rpt.summaryOnANewPage();
rpt.addSummary(cmp.text("REPORT SUMMARY"));
JasperPdfExporterBuilder pdfExporter = Exporters.pdfExporter("report.pdf");
rpt.toPdf(pdfExporter);
File file = new File("report.pdf");
response.setContentType("application/pdf");
return SUCCESS;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return ERROR;
}
But this is not working. It generates blank report. If I use rpt.addTitle(multiPageList);
instead of rpt.addDetail(multiPageList);
report generates but page header doesn't appear on each page.
Please help. Thanks in advance.