Hide Table of Contents
esri
Map
toolbars
Class: PrintTask
[ AMD Module Require | Legacy Module Require ]

Module Require

require(["esri/tasks/PrintTask", ... ], function(PrintTask, ... ){ ... });

Description

Class added 2.6
The PrintTask class generates a printer-ready version of the map using an Export Web Map Task available with ArGIS Server 10.1 and later. The PrintTask class is used when you want more granular control of the user interface for example, if you want to provide users the ability to define what appears on the printed page. View the Print widget for an out-of-the-box widget that provides a simple user interface for printing maps. 

The PrintTask requires an ArcGIS Server 10.1 Export Web Map Task. 

Samples

Search for samples that use this class.

Class hierarchy

esri.tasks.PrintTask

Constructors

ConstructorDescription
new PrintTask(url,params)Creates a new PrintTask object.

Properties

PropertyTypeDescription
urlStringThe url to the Export Web Map Task. Requires ArcGIS Server 10.1 or later.

Methods

MethodReturn ValueDescription
execute(printParameters?,callback?,errback?)dojo.DeferredSends a request to the print service resource to create a print page using the information specified in the printParameters argument. On completion, the onComplete event is fired and the optional callback function is invoked.

Events

[ On Style Events | Connect Style Events ]

All On Style event listeners receive a single event object. The event properties listed below are accessed from this event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
On EventEvent PropertiesDescription
complete<String> urlFired when the print operation is complete. Should be used in favor of onComplete
Constructor Details

new PrintTask(url,params)

Creates a new PrintTask object.
Parameters:
<String> urlRequiredThe url to the Export Web Map Task. Requires ArcGIS Server 10.1 or later.
<Object> paramsRequiredParameters for the print task. See the options table below for details on the parameters.
Options:
<Boolean> asyncSet to true if the print service is an asynchronous geoprocessing service.
Code Snippet:
require([
  "esri/tasks/PrintTask", ... 
], function(PrintTask, ... ) {
  var url ='http://servicesbeta4.esri.com/arcgis/rest/services/Utilities/ExportWebMap/GPServer/Export Web Map Task';
  var printTask = new PrintTask(url);
  ...
});
Property Details

<String> url

The url to the Export Web Map Task. Requires ArcGIS Server 10.1 or later.
Method Details

execute(printParameters?,callback?,errback?)

Sends a request to the print service resource to create a print page using the information specified in the printParameters argument. On completion, the onComplete event is fired and the optional callback function is invoked.
Return Value: dojo.Deferred
Input Parameters:
<PrintParameters> printParametersOptionalA PrintParameters object that defines the printing options.
<Function> callbackOptionalThe function to call when the method has completed. The arguments in the function are the same as the onComplete event.
<Function> errbackOptionalAn error object is returned if an error occurs during task execution.
Code Snippet:
require([
  "esri/map", "esri/tasks/PrintTask", "esri/tasks/PrintParameters", ... 
], function(Map, PrintTask, PrintParameters, ... ) {
  var map = new Map( ... );
  var printTask = new PrintTask( ... );
  var params = new PrintParameters();
  params.map = map;
  
  printTask.execute(params, printResult);
  ...
});
Event Details

[ On Style Events | Connect Style Events ]

complete

Fired when the print operation is complete. Should be used in favor of onComplete (Added at v3.5)
Event Properties:
<String> urlThe url to the printed resource