Jump to content
Changes to the Jaspersoft community edition download ×

jasper report print without dialog box


rovell74

Recommended Posts

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

  • 3 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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...