Jump to content

Update JRPdfExporter & JRExporterParameter to JasperReports Library 7.0.0


Go to solution Solved by voyager1,

Recommended Posts

Hello,
I'm trying to update my Java classes to the latest Libary version 7.0.0.

How do I have to change the code below? The JRPdfExporter and JRExporterParameter are probably deprecated.

JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, pdfFileName.getAbsolutePath());
exporter.setParameter(JRPdfExporterParameter.IS_CREATING_BATCH_MODE_BOOKMARKS, Boolean.TRUE);
exporter.exportReport();

 

Edited by voyager1
Link to comment
Share on other sites

  • voyager1 changed the title to Update JRPdfExporter & JRExporterParameter to JasperReports Library 7.0.0
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

I may have found a solution: 

 

File f = new File(this.fileName);
if (f != null) {
    try {
        JasperExportManager.exportReportToPdfFile(print, f.getAbsolutePath());
    } catch (JRException e) {
        LOG.error("Failed to generate report!", e);
    }
Link to comment
Share on other sites

  • 1 month later...

This is my sample code:

List reports = new ArrayList();
JasperPrint jpr;
for (int r = 0; r < rows.length; r++) {
   jpr = Print.printOrdineConferma();
   reports.add(jpr);
}
// reports is arrays of JasperPrint
List jasperPrintList = new ArrayList();
for (int x = 0; x < reports.size(); x++) {
   if (reports.get(x) == null)
      continue;
   jasperPrintList.add(reports.get(x));
}

// list is Array of pages varius printer

On jasper 6.21:

String nomeFile = Global.pathTemp + "stampaConfermaUnico.pdf";
File file = new File(nomeFile);

JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, nomeFile);
exporter.exportReport();

On jasper 7.0 

JasperExportManager.exportReportToPdfFile(...

not support parameter List!!!

 

Link to comment
Share on other sites

This solution work on list of reports:

         JasperPrint jpr;
         for (int r = 0; r < rows.length; r++) {
            jpr = Print.printOrdineConferma();
            if (jpr == null)
               return;
            reports.add(jpr);
         }
         try {
            String nomeFile = Global.pathTemp + "stampaConfermaUnico.pdf";
            File file = new File(nomeFile);

            JRPdfExporter exporter = new JRPdfExporter();
            exporter.setExporterInput(SimpleExporterInput.getInstance(reports)); //Set as export input my list with JasperPrint s
            exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(nomeFile)); //or any other out streaam
            SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
            configuration.setCreatingBatchModeBookmarks(true);
            exporter.setConfiguration(configuration);
            exporter.exportReport();
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...