voyager1 Posted July 11 Share Posted July 11 (edited) 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 July 11 by voyager1 Link to comment Share on other sites More sharing options...
Solution voyager1 Posted July 11 Author Solution Share Posted July 11 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 More sharing options...
matrixkatamail.com Posted September 4 Share Posted September 4 ok!! but if jasperPrintList is ArrayList how to exporter? Link to comment Share on other sites More sharing options...
matrixkatamail.com Posted September 5 Share Posted September 5 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 More sharing options...
matrixkatamail.com Posted September 5 Share Posted September 5 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now