Getting error while printing jasper report from java Caused by: java.awt.print.PrinterException: No print service found -


caused by: java.awt.print.printerexception: no print service found. @ sun.print.rasterprinterjob.print(rasterprinterjob.java:1305) @ sun.print.rasterprinterjob.print(rasterprinterjob.java:1277) @ net.sf.jasperreports.engine.print.jrprinterawt.printpages(jrprinterawt.java:205)

error getting when trying print jasperreports report java code

below code tried, works in os problem in window7

 try {     string report = args[0];     string printtext = args[1];     string expirydate = args[2];     string printername = args[3];      hashmap hm = new hashmap();     hm.put("printtext", printtext);     hm.put("expirydate", expirydate);      inputstream templateasstream = classloader.getsystemresourceasstream(report);      system.out.println(" \n compile report");     jasperreport jasperreport = jaspercompilemanager.compilereport(templateasstream);      // submit parameters      map parameters = new hashmap();     parameters.put("param1", "jasper report ...");     parameters.put("param2", "...rules");      system.out.println("fill compiled template");      jasperprint jp = jasperfillmanager.fillreport(jasperreport, hm, new jremptydatasource());      system.out.println("\n page count" + jp.getpages().size());      printrequestattributeset printrequestattributeset = new hashprintrequestattributeset();     printserviceattributeset printserviceattributeset = new hashprintserviceattributeset();      printserviceattributeset.add(new printername(printername, null));     printrequestattributeset.add(new copies(1));      jrprintserviceexporter exporter = new jrprintserviceexporter();      exporter.setparameter(jrexporterparameter.jasper_print, jp);     exporter.setparameter(jrprintserviceexporterparameter.print_request_attribute_set, printrequestattributeset);     exporter.setparameter(jrprintserviceexporterparameter.print_service_attribute_set, printserviceattributeset);     exporter.setparameter(jrprintserviceexporterparameter.display_page_dialog, boolean.false);     exporter.setparameter(jrprintserviceexporterparameter.display_print_dialog, boolean.false);      system.out.println("export printer");      jasperprintmanager.printreport(jp, false); } catch (exception ex) {     ex.printstacktrace(system.out);     system.out.println("died"); } 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -