views:

93

answers:

1

Is there a way to print only specific pages in jasper. I need it for pagination purpose.

ex: if I have 20 pages, i should be able to get jasper to generate one page report at a time. Can i pass the page number as a param?

+2  A: 

Answering my own question,

Yes it is possible.. atleast in case of HTML and csv reports. The code that does this is below.

JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(3));
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"d://ReportResult//FinalReportResult.html");

Once this is set, just do a

exporter.exportReport();

In the above case, page number 4, i.e, index 3 is exported to the HTML file.

Vaishak Suresh