2004 IR Help Posted August 22, 2006 Share Posted August 22, 2006 By: viji - vijinarayanan defining a printer when printing jasper 2005-07-19 01:02 if i click printer for jasper report,it prints on the server's default printer.it is possible to print the reports on the other network printer (client printers)? if so,i had the program to list the printers in the server,but i don't know to pass the report to the client printer?help me to do this. thanks in advance. viji. By: Dave G - dgarratt RE: defining a printer when printing jasper 2005-07-19 11:44 I have a look at this code, it allows you to print to a nominated printer by name. However what I want to do is invoke the JasperViewer dialog and pass the default printer to that, but I don't know how to do that. public static void run(String ReportName,Map parameters) { try { JasperReport jasperReport = (JasperReport) JRLoader.loadObjectFromLocation(ReportName+".jasper"); Connection conn = Common.selectedHost.db.conn; JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); JRPrintServiceExporter exporter = new JRPrintServiceExporter(); exporter.setParameter( JRPrintServiceExporterParameter.JASPER_PRINT, jasperPrint); PrintServiceAttributeSet serviceAttributeSet = new HashPrintServiceAttributeSet(); serviceAttributeSet.add(new PrinterName(JPrint.getPrinterShortName("My printer queue name",null)); exporter.setParameter( JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE); exporter.exportReport(); //JasperViewer.viewReport(jasperPrint,false); } catch (Exception e) { JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE); } } 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