prints the report in pdf format.
//import it in the java file import net.sf.jasperreports.engine.JasperExportManager; // a function ehich calls the jasper to generate the report private String generatePldbbyCC(ParameterReportCriteria prcObject, Map reportMap) throws Exception { JasperPrint jasperPrint = null; JRFileVirtualizer virtualizer = null; String destFileLoc = null; File sourceFile = null; File destFile = null; ESpecDAOController control = new ESpecDAOController(); // puts the parameters to jasper. parameters.put(Constants.COMPETITIVE_CATEGORIES, prcObject.getSelectedCompCategs()); parameters.put("REPORT_CONNECTION", control.getMasterConnection()); parameters.put(EspecConstants.CURR_TIME, "Exported: " + new SimpleDateFormat("M/d/yyyy 'at' hh:mm:ss a").format(DateUtil.getCurrentDateTime())); PropertiesVO templatePath = setJasperpath(); virtualizer = new JRFileVirtualizer(1, templatePath.getValue()); parameters.put(SUBREPORT_DIR, templatePath.getValue()); parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); try { jasperPrint = JasperFillManager.fillReport(templatePath.getValue() + "/sample.jasper", parameters, control.getMasterConnection()); } else { //get the file with extension as pdf destFile = new File(templatePath.getValue(), jasperPrint.getName() + "_" + prcObject.getProcessId() + ".pdf"); } destFileLoc = destFile.toString(); //exports the report as pdf. JasperExportManager.exportReportToPdfFile(jasperPrint,destFileLoc);