2005 IR Help Posted August 27, 2006 Share Posted August 27, 2006 By: Kukku - kukku Unanswered Question !!! Report Printing 2004-09-24 07:18 I am generating the jasper reports.It all works fine. What I want is to print this report directly to printer. From my machine it works fine as webapp is deployed on my machine,but when I try to print this report from another machine I am not able to do this. My problem is how an application get the printer at client side to print report at their end. I am using the following code. JasperPrint jasperPrint = null; try { jasperPrint = JasperFillManager.fillReport( jasperFileName, parameters, new JRBeanCollectionDataSource(reportData)); } catch (JRException je) { System.out.println( "Error printing report:n" + je.getMessage()); return; } PrinterJob pj = PrinterJob.getPrinterJob(); if (pj.printDialog()) { PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); //printRequestAttributeSet.add(OrientationRequested.LANDSCAPE); //printRequestAttributeSet.add(MediaSizeName.ISO_A4); PrintServiceAttributeSet printServiceAttributeSet = PrinterJob.getPrinterJob().getPrintService().getAttributes(); PrinterName printerName = new PrinterName("normal", Locale.getDefault()); printServiceAttributeSet.add(printerName); JRPrintServiceExporter exporterjasper = new JRPrintServiceExporter(); exporterjasper.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet); exporterjasper.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); exporterjasper.setParameter( JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet); exporterjasper.setParameter( JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet); exporterjasper.setParameter( JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporterjasper.setParameter( JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE); try { exporterjasper.exportReport(); } catch (JRException je) { System.out.println( "Error printing report:n" + je.getMessage()); } } I will really appriciate if some body helps me out. Thanks. By: Tahir Emre KALAYCI - tekrei RE: Unanswered Question !!! Report Printing 2004-12-29 05:40 Hello. Could you solve this problem? i am facing this problem too. And couldnt find a resource about it? 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