How do i save same pdf file generated from jasper in java without overriding the existing pdf file like report1, report2, report 3 etc Note: its a java application not for web application, but solutions for both would be helpful.
enter code here
JRDesignQuery newQuery = new JRDesignQuery();
newQuery.setText(sql1);
jd.setQuery(newQuery);
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(jr, null,con);
JasperExportManager.exportReportToPdfFile(jp,reportDest);
JasperViewer.viewReport(jp); '
i figured out the best solution for save the same file with a different name without overriding the existing file
added this code before the code.I am appending the date and time to the file and hence files with different time and date will be stored in the same directory for a jasper report.
enter code here
String file = "filename_";
// display time and date using toString()
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-hh.mm.ss");
String dateString = formatter.format(date);
JasperExportManager.exportReportToPdfFile(jp,reportDest+file+dateString+".pdf");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments