Jump to content

Problem with JRPrintServiceExporter.exportReport


dany

Recommended Posts

Sometimes JasperPrintManager.printReport() and JRPrintServiceExporter.exportReport() produce different results. When I print to default printer using JasperPrintManager.printReport() it's all fine. But when I print to a specific printer using JRPrintServiceExporter.exportReport() it's produce the different result - the last 3cm on the page not printing at all. I deep in Jasper sources and find that call JasperPrintManager.printReport() ends in JRPrinterAWT.printPages when magic happens. But method JRPrintServiceExporter.exportReport() not using JRPrinterAWT.printPages and do all work itself. Therefore the Jasper prints to default printer and to the specific printer in different ways. What's the right way using JRPrintServiceExporter.exportReport()?
 

if (jasperPrinter == null)
   JasperPrintManager.printReport(jasperPrint, withPrintDialog);
else {
    PrintService printService = printOptions.getPrintService(jasperPrinter);

    JRExporter exporter = new JRPrintServiceExporter();
    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 dany305 at 06/03/2010 15:51



Post Edited by dany305 at 06/03/2010 15:53



Post Edited by dany305 at 06/10/2010 12:31
Link to comment
Share on other sites

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

Top Posters In This Topic

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