Printing reports
There are five methods provided for printing a report.
- printReport()
- printReport(Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground, boolean bUseJDK11)
- printReport(Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground, boolean bUseJDK11, boolean bSeparateLargePage)
- printReport(java.lang.Object job, boolean bInteractive, java.lang.Object pf, boolean bInBackground, JReportPrintListener jreportprintlistener, int useJDK, java.lang.String jobName, java.util.Vector attributeInfo, java.lang.String printer)
- getPrintStatus()
Parameters
Example 1
With JDK1.2 or later, if you use the JDK1.2 printing method (boolean bUseJDK11), you can call the printReport method as shown below:
PrinterJob printJob=PrinterJob.getPrinterJob();
bean.printReport(printJob, printJob.defaultPage(), false, false, false);
Or, if you do not want to use getPrinterJob, you can simply call:
bean.printReport(null, null, false, false, false);
Example 2
With JDK1.2 or later, if you use the JDK1.1 printing method, you are best recommended not to use getPrintJob, instead you can call:
bean.printReport(null, null, false, false, true);
Notes:
- The first method printReport() is called to start printing. It will take the third method using default parameter values such as:
printReport(null, null, true, false, false, false)
- The second and third method allows you to pass the parameters - printJob, pageFormat, bInteractive, bInbackground, bUseJDK11 and bSeparateLargePage.
- The third printing method (with the bSeparateLargePage parameter) is not recommended. It may cause some unexpected errors, for example, you may get an extra blank page.
- After printing has started, the method getPrintStatus() can be used to get the print job status. Returned values of getPrintStatus() are:
"No print job"
"Busy"
"OK"
"No report load"
Other error messages if there are errors.