rovell74 Posted June 14, 2020 Share Posted June 14, 2020 I'm using JasperReports to generate pdf and put it to the OutputStream. It it possible to send pdf directly to a printer without displaying dialog box to select the printer?The code i use is JasperPrint jasperPrint = null; response.setContentType("application/x-download"); response.setHeader("Content-Disposition", String.format("attachment; filename=""+fileName+""")); OutputStream out = response.getOutputStream(); String path = resourceLoader.getResource(reportResource).getURI().getPath(); JasperReport jasperReport = JasperCompileManager.compileReport(path); //Map<String, Object> parameters = new HashMap<String, Object>(); jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource); //JasperExportManager.exportReportToPdfStream(jasperPrint, out); /**/ JRPdfExporter exporter = new JRPdfExporter();//tJasperReportsContext.getInstance()); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); if (printDialog) { configuration.setPdfJavaScript("this.print()"); } exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(out)); exporter.setConfiguration(configuration); exporter.exportReport(); Thank Link to comment Share on other sites More sharing options...
alfpunk Posted June 30, 2020 Share Posted June 30, 2020 Looks like this is an answer to your questionhttps://stackoverflow.com/questions/31028896/how-to-print-jasper-reports-in-a-specified-printer 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