By: daniel schulken - danielschulken add ability to pass print service 2003-12-31 06:51 Sorry about the formatting. This allows for a printservice to be specified to print to. I really wasnt sure where else to send this. added to JasperPrintManager.java public static boolean printReport( PrintService printService, JasperPrint jasperPrint, boolean withPrintDialog ) throws JRException { return printPages( printService, jasperPrint, 0, jasperPrint.getPages().size() - 1, withPrintDialog ); } public static boolean printPages( PrintService printService, JasperPrint jasperPrint, int firstPageIndex, int lastPageIndex, boolean withPrintDialog ) throws JRException { return JRPrinterAWT.printPages( printService, jasperPrint, firstPageIndex, lastPageIndex, withPrintDialog ); } added to JRPrinterAWT.java public static boolean printPages( PrintService printService, JasperPrint jrPrint, int firstPageIndex, int lastPageIndex, boolean withPrintDialog ) throws JRException { JRPrinterAWT printer = new JRPrinterAWT(jrPrint); return printer.printPages( printService, firstPageIndex, lastPageIndex, withPrintDialog ); } private boolean printPages( PrintService printService, int firstPageIndex, int lastPageIndex, boolean withPrintDialog ) throws JRException { boolean isOK = true; if (firstPageIndex < 0 || firstPageIndex > lastPageIndex || lastPageIndex > jasperPrint.getPages().size()) { throw new JRException( "Invalid page index range : " + firstPageIndex + " - " + lastPageIndex + " of " + jasperPrint.getPages().size() ); } pageOffset = firstPageIndex; PrinterJob printJob = PrinterJob.getPrinterJob(); PageFormat pageFormat = printJob.defaultPage(); Paper paper = pageFormat.getPaper(); switch (jasperPrint.getOrientation()) { case JRReport.ORIENTATION_LANDSCAPE : { pageFormat.setOrientation(PageFormat.LANDSCAPE); paper.setSize(jasperPrint.getPageHeight(), jasperPrint.getPageWidth()); paper.setImageableArea( 0, 0, jasperPrint.getPageHeight(), jasperPrint.getPageWidth() ); break; } case JRReport.ORIENTATION_PORTRAIT : default : { pageFormat.setOrientation(PageFormat.PORTRAIT); paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight()); paper.setImageableArea( 0, 0, jasperPrint.getPageWidth(), jasperPrint.getPageHeight() ); } } pageFormat.setPaper(paper); Book book = new Book(); book.append(this, pageFormat, lastPageIndex - firstPageIndex + 1); printJob.setPageable(book); try { printJob.setPrintService(printService); if (withPrintDialog) { if (printJob.printDialog()) { printJob.print(); } else { isOK = false; } } else { printJob.print(); } } catch (Exception ex) { throw new JRException("Error printing report.", ex); } return isOK; } By: Umberto Uderzo - uuderzo RE: add ability to pass print service 2004-01-05 02:07 Hi Daniel. you can specify a print service using somethign similar to this one: PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); printServiceAttributeSet.add( new PrinterName( "printer service name" , null )); JRPrintServiceExporter exporter = new JRPrintServiceExporter(); exporter.setParameter( JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet); exporter.setParameter( JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter( JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE); exporter.exportReport(); You will need to set also the stream to be exported.