We are using jasper API (JasperFillManager.fillReport,JasperExportManager.exportReportToPdfFile)
We want to execute that report in the loop with different parameters, so added following code
JasperPrint jasperPrint = null;
// Fill report
Iterator i1 = l1.iterator();
Iterator i2 = l2.iterator();
int i = 1;
while (i1.hasNext() && i2.hasNext()) {
parameters.put("SUBJECTOID", (String) i1.next());
parameters.put("HISTORYRECORD", (String) i2.next());
try (ProfilePoint fillReport = ProfilePoint
.profileAction("ProfAction_ReportHelper_fillJasperReport")) {
jasperReport = JasperCompileManager.compileReport(jrxmlPath);
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, emptyDataSource);
System.out.println("fillReport**********" + i);
}
// Export to PDF
try (ProfilePoint exportReport = ProfilePoint
.profileAction("ProfAction_ReportHelper_exportJasperReport")) {
JasperExportManager.exportReportToPdfFile(jasperPrint,
"C:\\JASPER\\JASPEROUTPUT\\Report" + i + ".pdf");
System.out.println("exportReportToPdfFile**********" + i);
}
i++;
jasperPrint = null;
jasperReport = null;
So what happens we have 15 Parameteres , so 15 PDF files gets generated , but only first PDF file contains data, other 14 are blank.
We tried multiple things such as compiling once , compiling multiple times, extracted jasper code to method but still outcome is the same
Is there any cache or some kind of setting in jasper or similar something?
Thanks @ dada67 for suggestion it worked
I have passed new emptydatasource for each iteration and it worked.
Thanks a lot..!!!