Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: PrintTask

dojo.require("esri.tasks.PrintTask");

Description

(Added at v2.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.

Known limitations: If the map contains a VectorTileLayer that uses the World Basemap service and the VectorTileLayer is not a basemap reference layer, then the print task will use the World Street Map raster tiles in the printout; otherwise, the VectorTileLayer will not be included in the layout.

Samples

Search for samples that use this class.

Constructors

NameSummary
new esri.tasks.PrintTask(url, params?)Creates a new PrintTask object.

Properties

NameTypeSummary
urlStringThe url to the Export Web Map Task.

Methods

NameReturn typeSummary
execute(printParameters, callback?, errback?)DeferredSends a request to the print service resource to create a print page using the information specified in the printParameters argument.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
complete
{
  result: <DataFile>
}
Fired when the print operation is complete.
error
{
  error: <Error>
}
Fired when an error occurs while executing the print task.
Constructor Details

new esri.tasks.PrintTask(url, params?)

Creates a new PrintTask object.
Parameters:
<String> url Required URL to the Export Web Map Task. Requires ArcGIS Server 10.1 or later.
<Object> params Optional Parameters for the print task. See the options table below for details on the parameters.
params properties:
<Boolean> async Optional Set to true if the print service is an asynchronous geoprocessing service.
Sample:
var url ='http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task';
var printTask = new esri.tasks.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 type: Deferred
Parameters:
<PrintParameters> printParameters Required A PrintParameters object that defines the printing options.
<Function> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onComplete event.
<Function> errback Optional An error object is returned if an error occurs during task execution.
Sample:
var params = new esri.tasks.PrintParameters();
params.map = map;

printTask.execute(params, printResult);
Event Details
[ On Style Events | Connect Style Event ]

complete

Fired when the print operation is complete. Should be used in favor of onComplete. (Added at v3.5)
Event Object Properties:
<DataFile> result A DataFile that contains the url of the printed image.

error

Fired when an error occurs while executing the print task. (Added at v3.6)
Event Object Properties:
<Error> error Error message returned in a JavaScript error object.