Printing Reports
There are four methods provided for printing the 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 (Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground,
boolean bUseJDK11, boolean bSeparateLargePage, String jobName)
printReport (Object printJob, Object pageFormat, boolean bInteractive, boolean bInBackground,
boolean bUseJDK11, boolean bSeparateLargePage, String jobName, String printer)
getPrintStatus ( )
Parameters:
printJob -- The job of this printing.
pageFormat -- Description for the size and orientation of a page to be printed.
bInteractive -- A boolean value. If you set it to false, the print setup dialog will not show up.
bInBackground -- A boolean value. If you set it to true, the printing dialog will not show up.
bUseJDK11 -- A boolean value. If you set it to true, it will use JDK1.1.x to print the report. Otherwise if you set false, it will use the JDK which you are running to print the report. The JDK 1.1 printing method is quick in speed but the printing quality is not guaranteed. The JDK 1.2 method can give you a satisfactory result, even for a gif file, but it is slow in speed.
bSeparateLargePage -- A boolean value, if the report page size is larger than the print paper size, and you want to separate the large report page during printing, you should set this property to true. If the print page size which you choose is less than the report page size, then the report will be printed as multiple pages serially, this means we will separate the large page of the report automatically. After you set it to true, for JDK1.2 or higher, the page format dialog will be popped up. In this dialog, you can choose the page format which you want to print with, we will use this page size for printing. For JDK1.1.x, however, you must change the page format which you want to print with in the print dialog (click the property button, then choose the page format).
jobName -- A String value of the job name. When printing, the job name you defined will list in the window which shows information, such as the status of documents and the owner of a document etc.
printer -- The name of the printer used to print the report. Please note that if you set bUseJDK11 to be false, you can't set printer but use the default printer only.
Note:
The first method printReport ( ) is called to start printing. It will take the third method using the default parameter values like this:
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 is 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.
Example1: Under JDK1.2 or higher, if you use JDK1.2 printing method (boolean bUseJDK11), you can call the printReport method like this:
PrinterJob printJob = PrinterJob.getPrinterJob();
bean.printReport(printJob, printJob.defaultPage(), false, false, false);
Or, if you do not want to getPrinterJob, simply call:
bean.printReport(null, null, false, false, false);
Example2: Under JDK1.2 or higher, if you use JDK1.1 printing method, you are best recommended not to getPrintJob, just call:
bean.printReport(null, null, false, false, true);
Example 3: Under JDK 1.2 or higher, if you use JDK1.1 printing method and select a network printer, you can call the printReport method like this:
bean.printReport(null, null, false, false, true, false, "job1", "\\\\GUOF\\HP LaserJet 6L Pro PCL5e");
Example 4: Under JDK 1.2 or higher, if you use JDK1.1 printing method and select a local printer, you can call the printReport method like this:
bean.printReport(null, null, false, false, true, false, "job1", "HP LaserJet 6L Pro PCL5e");
|