PrintTask control


In this topic


About the PrintTask control

Use the PrintTask control to print a map, task results, legend, scale bar, copyright, and north arrow. The task allows you to set various properties for the print page. You can control the options that appear on the Print Options dialog box and what displays on the print page. The print task generates a new Web browser window with the print page preview. You can then print the page to any available printer locally or on the network.
For more information, see Working with print task control.

Using the control

  1. To add controls to the page, open Visual Studio and set up a Web application with MapResourceManager and Map controls. Add one or more tasks, such as a QueryAttributesTask to the page if you want to print the task results. If you add tasks, also add a TaskResults control. At runtime, the TaskResults control displays the results of the task operation. Set the Map property of the TaskResults control to the previously added Map control to view results highlighted on the map when selected. If needed, also add a TaskManager and Menu control to open tasks from the menu. Optionally, add other controls, such as the Toc control. It is not necessary to add a Toc control on the page to have the PrintTask control display a legend, since the PrintTask control generates its legend internally.
  2. To add a PrintTask control, open the page's Web form in design mode. Select the Toolbox panel and expand the ArcGIS Web Controls tab. Drag and drop a PrintTask onto the page. See the following screen shot that shows the page in Visual Studio in a table layout:



  3. Select the PrintTask to set its properties. The smart tag arrow displays in the upper-right corner of the control. Click the smart tag arrow. The smart tag menu appears with common properties that you can set. Other properties are also available on the Properties window for the control. See the following screen shot:

    PrintTask smart tag
    1. Choose Task Results container—Click this option on the smart tag menu (see the preceding screen shot) to choose the task results container or click the TaskResultsContainers property button on the Properties window. The BuddyControl Collection Editor dialog box appears. Click Add under the Members area to add an item to the collection. Select the TaskResults1 item, click the drop-down list, and select the previously added TaskResults control. The PrintTask prints results that appear in this task results container. If this property is not set, results are not available for printing on the PrintTask dialog box. See the following screen shot:

      QueryAttributesTask result container dialog

    2. Select Legend Layers—To omit map layers from the printed legend, click Select Legend Layers on the previous smart tag menu. The Select Legend Layers dialog box appears. Expand the MapResource node and clear the layer check box or check boxes to hide from the legend. Click OK to save the settings. See the following screen shot:

      PrintTask - select legend layers 
  4. You can also set the following properties for the PrintTask:
    • Title—Shows at the top of the print form on the Web site. Change the default, which is the control's ID. For example, choose a title, such as "Print" or "Print the map and data."
    • ButtonText—Text for the button that creates the print preview page. The default is "Create Print Page."
    • LegendSettings—Sets the number of columns in the legend, if the legend is condensed (if not condensed, prints all resource item names and group layer names), if the legend prints by default (DefaultValue), if an option to print the legend is included on the user dialog box (false by default), and hidden layers, if any. Use the Select Legend Layers (see Step 3) smart tag to edit the hidden layers.
    • MapSettings—Sets whether the map prints by default (DefaultValue) and if an option to print the map is available (DisplayInDialog).
    • NorthArrowSettings—Sets whether the north arrow prints by default (DefaultValue) and if an option to print the north arrow is available. (DisplayInDialog)
    • QualitySettings—Affects the quality of the map when printed. Sets the default dots per inch (dpi) setting for the map (DefaultValue), if the option to change the quality (DisplayInDialog) is available, and the list of map quality settings that will be in the user dialog box if DisplayInDialog is set to true. To edit the QualityList, click the ellipsis button next to the list.
    • ResultsVisible—Whether the Print dialog box on the Web site includes a list of task results to print. Set to false if the TaskResultsContainer where the PrintTask is located has one or more tasks, but you do not want results printed from those tasks.
    • ScaleBarSettings—Sets whether the scale bar prints by default (DefaultValue) and if an option to print the scale bar is available (DisplayInDialog).
    • TitleSettings—Sets the title of the printed page that is used unless it is changed by the user (DefaultValue) and if an option to view and change the title is available (DisplayInDialog).
    • WidthSettings—Determines the size of the printed map. The size is set based on the necessary width. The map's height is automatically proportioned to the current map on the Web page. Sets the default width (DefaultValue), whether the Print dialog box includes an option to change the width (DisplayInDialog), and the list of width settings that display on the Print dialog box if DisplayInDialog is set to true. To edit the WidthList, click the ellipsis button next to the list and edit the values on the dialog box that appears. Each size can be assigned a name and width value in inches or centimeters.
    • LayoutTemplateFile—Path to the file that defines the inclusion and arrangement of elements on the print page. You can do the following by creating a custom template file:
      • Specify the appearance and placement of standard print page elements—map, legend, title, task results, copyright title, and copyright text.
      • Include custom elements, such as company logos.
      • Display dynamic information, such as time stamps and user logins.
      • Manipulate task results to perform analyses and create advanced visualizations (for example, charts).
      • Use JavaScript and ASP.NET to enable interactivity.
  5. The PrintTask dialog box displays printing options based on the settings at design time. Modify the settings for the title, map size, select task results (if any) to print, and create the print page. Creating the print page opens a new Web browser window or tab, and the print page shows in a new window. You can then use the Web browser's print functions to print the page. The following screen shot shows the default PrintTask dialog box at runtime:

    Print task at runtime 

Members

The following table shows a list of properties related to the PrintTask control. For more reference information, see the PrintTask control in the library reference section.
Property name
Type
Description
ButtonText
string
Text that appears on the button to execute the task.
LegendSettings
LegendItemSettings
Settings for printing the legend on the print page.
MapSettings
ItemSettings
Settings that determines if the map prints.
NorthArrowSettings
NorthArrowSettings
Settings to print the north arrow on the print page.
QualitySettings
QualityItemSettings
Settings for the quality (dpi) of the map on the print page.
ResultsVisible
Boolean
Whether the list of task results displays on the Print dialog box enabling you to print the task results.
ScaleBarSettings
ItemSettings
Settings for whether the scale bar displays on the print page.
TitleSettings
ItemSettings
Settings for the title on the print page.
WidthSettings
WidthItemSettings
Settings for the size (based on the width) of the map on the print page.
ActivityIndicatorImage
string
Uniform resource locator (URL) of the image to display while a task is executing.
ActivityIndicatorLocation
TaskActivityIndicatorLocation
Location of an animated image that shows while the task is executing.
NavigationPath
string
Path to the task as it appears in a hierarchical data control buddied to the task's TaskManager.
Map
string
ID of the Map control used as the source for the printed map.
MapCopyrightText
string
ID of the MapCopyrightText control used for printing a copyright statement on the printed page.
TaskResultsContainers
BuddyControlCollection
Controls in which results from the task are displayed.
LayoutTemplateFile
string
Path to the file specifying the layout of the print page.


See Also:

Web controls
Customizing the Web Mapping application




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
  • ESRI.ArcGIS.ADF.Tasks.dll