xuyun Posted October 8, 2006 Share Posted October 8, 2006 I want to select a printer(not the default printer) only once, than print all the reports to the selected printer?Is it possible?//this dose not work for multi-report printingJasperPrintManager.printReport(jasperPrint, (i == 0)); Regards. Link to comment Share on other sites More sharing options...
C-Box Posted October 9, 2006 Share Posted October 9, 2006 Just make a simple loop around your print command after you selected the printer! :-) like:Code:int copyNumbers = 1;for (int i = 0; i < copyNumbers; i++) { //print without dialog} hthC-Box Link to comment Share on other sites More sharing options...
xuyun Posted October 11, 2006 Author Share Posted October 11, 2006 if (JasperPrintManager.printReport(jasperPrint1, true)) { JasperPrintManager.printReport(jasperPrint2, false);} jasperPrint1 and jasperPrint2 are the same report with different data, user should select a printer, say "Printer1"(not default printer), before printing jasperPrint1.But after jasperPrint1 was printed jasperPrint2 shall be printed to "Printer1" directly without showing PrintDialog. Is it possible? Link to comment Share on other sites More sharing options...
Teodor Danciu Posted October 11, 2006 Share Posted October 11, 2006 Hi, I think what you are saying has something to do with this feature request here:http://jasperforge.org/sf/go/artf1642?nav=1 But, I think what you could do is to show the print dialog for picking the print service somewhere in your application, prior to actually calling the JRPrintServiceExporter and then pass the selected printer by name to the exporter. Check the /demo/samples/printservice sample provided for details about how to print to a specific printer by name. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
xuyun Posted October 12, 2006 Author Share Posted October 12, 2006 Thanks, it works, but the printservice sample dose not use PRINT_SERVICE parameter. my code like:Code:PrinterJob printerJob = PrinterJob.getPrinterJob();printerJob.getPrintService();if (!printerJob.printDialog()) { return false;}PrintService printService = printerJob.getPrintService();JRPrintServiceExporter exporter = new JRPrintServiceExporter();for (int i = 0; i < list.size(); i++) { Map parameters = new HashMap(); JRDataSource ds = new JRBeanCollectionDataSource((List) list.get(i)); JasperPrint jasperPrint = JasperFillManager.fillReport("reportName.jasper", parameters, ds); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, printService); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,Boolean.FALSE); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,Boolean.FALSE); exporter.exportReport();}Post edited by: xuyun, at: 2006/10/12 01:33 Link to comment Share on other sites More sharing options...
xuyun Posted November 2, 2006 Author Share Posted November 2, 2006 How to print 2 copied, if user selected in the printer dialog. Link to comment Share on other sites More sharing options...
xuyun Posted November 2, 2006 Author Share Posted November 2, 2006 How to print 2 copied, if user selected in the printer dialog. Link to comment Share on other sites More sharing options...
C-Box Posted November 2, 2006 Share Posted November 2, 2006 Just pass the number of copies as parameter to the fill engine (so you have to show the printer dialog before calling the fill-method of course) hthC-Box 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