Jump to content
We've recently updated our Privacy Statement, available here ×

JASPER_PRINT_LIST with JRPrintServiceExporter


marcin

Recommended Posts

Some time ago someone reported a bug where JRPrintServiceExporter was not working with JASPER_PRINT_LIST.

(http://www.jasperforge.org/sf/go/artf1455;jsessionid=E6123CCFB152B5A860B9E3ACA9125CC2?nav=1)

 

The bug is closed, but when I'm trying to print multiple reports, I'm still getting only the first page printed.

 

Does printing multiple reports require some special handling?

 

This is my code, the commented lines does not make any difference:

 

Code:

private void exportToPrinter(Report report, List records, List printJobs) throws Exception {
JRPrintServiceExporter exporter = new JRPrintServiceExporter();

/*
HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MultipleDocumentHandling.SEPARATE_DOCUMENTS_COLLATED_COPIES);
aset.add(PrintQuality.DRAFT);
aset.add(SheetCollate.COLLATED);
aset.add(new PageRanges(1,printJobs.size()));

exporter.setParameter( JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, aset);
*/

exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, printJobs);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);

exporter.exportReport();
}

 

Regards

Marcin

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

No one replied to my question, that is sad.

I think this forum is not in it best shape.

 

JASPER_PRINT_LIST in jasper 1.3.0 started to work, but it still keeps all printjobs separate, making some tricks like printing multiple pages on one sheet, or printing only even pages impossible. Not mentioning having 1200 dialogs displayed for 1200 separate printjobs.

 

Anyway, I found a workaround, so if someone is having similar problems, this code will merge all separate JasperPrint objects into one:

Code:

JasperPrint finalJob = null;
for (int i=0; i<jasperPrintJobs.size();i++ ) {
if (finalJob == null) {
finalJob = ((JasperPrint)jasperPrintJobs.get(i));
} else {
for (int j=0;j<((JasperPrint)jasperPrintJobs.get(i)).getPages().size();j++) {
finalJob.addPage((JRPrintPage) ((JasperPrint)jasperPrintJobs.get(i)).getPages().get(j));
}
}
}
exporter.setParameter(JRExporterParameter.JASPER_PRINT, finalJob);

 

I hope that JASPER_PRINT_LIST behaviour will be fixed one day.

 

Regards

Marcin

Post edited by: marcin, at: 2007/01/02 02:01

Link to comment
Share on other sites

  • 1 year 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...