How to Specify Weekdays as Nonworking Days

Using ADF Gantt Chart Components 28-23

28.9.1 Print Options

In general, the GanttPrinter class prints the Gantt chart content as it appears on your screen. For example, if you hide the legend in the Gantt chart, then the legend will not be printed. Similarly, if you deselect a column in the List Pane section of the View Menu, then that column will not be visible in the Gantt chart and will not appear in the printed copy unless you take advantage of the column visibility print option. You can use the following print options in the GanttPrinter class: ■ Column visibility: The setColumnVisible method lets you control whether individual columns in the list region of the Gantt chart will appear in the printed output. For example, to hide the first column in the list region of a Gantt chart, use the following code, where the first parameter of the method is the zero-based index of the column and the second parameter indicates if the column should be visible in the printed Gantt chart: _printer.setColumnVisibleo, false; ■ Margins: The setMargin method of the GanttPrinter lets you specify the top, bottom, left, and right margins in pixels as shown in the following code, where _ printer is an instance of the GanttPrinter class: _printer.setMargin25, 16, 66, 66; ■ Page size : The setPageSize method of the GanttPrinter class lets you specify the height and width of the printed page in pixels as shown in the following code, where _printer is an instance of the GanttPrinter class: _printer.setPageSize 440, 600; ■ Time period : The setStartTime and setEndTime methods of the GanttPrinter class let you identify the time period of the Gantt chart that you want to print. Example 28–18 shows sample code for setting a specific time period in the Gantt chart for printing, where startDate and endDate are variables that represent the desired dates and _printer is an instance of the GanttPrinter class. Example 28–18 Code for Setting the Time Period Option for Printing a Gantt Chart _printer.setStartTimestartDate; _printer.setEndTimeendDate;

28.9.2 Action Listener to Handle the Print Event

The Gantt chart toolbar includes a print button that initiates a print action. To print a Gantt chart, you must create an ActionListener to handle the print event. The code in the ActionListener should include the following processes: 1. Access the servlet’s output stream. 2. Generate the FO. This process includes creating an instance of the GanttPrinter class and entering the code for any print options that you want to use. 3. Generate the PDF. Example 28–19 shows the code for an ActionListener that handles the print event. This listener includes settings for all the print options available in the GanttPrinter helper class.