Jump to content
JasperReports Library 7.0 is now available ×

How to print report twice but showDialog only once


xuyun

Recommended Posts

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 printing

JasperPrintManager.printReport(jasperPrint, (i == 0));

 

Regards.

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

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

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

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

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...