Realshit Posted January 23, 2007 Share Posted January 23, 2007 Hi.I´m trying to print a report, and when I choose the default printer, it works fine. Now, I want to let the user choose the printer, and I don´t know how do it. I´m doing the printing like this JRExporter exporter = new JRPrintServiceExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jPrint); exporter.setParameter(JRPrintServiceExporterParameter. PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes()); exporter.setParameter(JRPrintServiceExporterParameter. DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter. DISPLAY_PRINT_DIALOG, Boolean.FALSE); exporter.exportReport(); Then, I need a PrintService (service), but with Java, when I open the standard dialog to choose printer (like this) PrintJob miPrintJob = frame.getToolkit().getPrintJob( frame,"Select Printer",null );I only can get a graphics, not a PrintService, and I need this PrintService. Can you help me ?? Thanks in advance.Post edited by: Realshit, at: 2007/01/23 12:59 Link to comment Share on other sites More sharing options...
Fadjer Posted February 5, 2007 Share Posted February 5, 2007 Hi, Did you find any solution to your problem ? I'm having the same issue. Thanks in advance. Link to comment Share on other sites More sharing options...
wegnerk Posted February 5, 2007 Share Posted February 5, 2007 i also had that problem and for me, it worked like this: Code:PrinterJob job = PrinterJob.getPrinterJob();PrintService service = job.getPrintService();PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();printRequestAttributeSet.add(MediaSizeName.ISO_A4);JRPrintServiceExporter exporter = new JRPrintServiceExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes());exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);exporter.exportReport(); 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