Description
Class added 2.6The 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
Properties
| url | String | The url to the Export Web Map Task. Requires ArcGIS Server 10.1 or later. |
Methods
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.
| complete | <String> url | Fired 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> url | Required | The url to the Export Web Map Task. Requires ArcGIS Server 10.1 or later. |
| <Object> params | Required | Parameters for the print task. See the options table below for details on the parameters. |
Options:
| <Boolean> async | Set 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
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.
Input Parameters:
| <PrintParameters> printParameters | Optional | 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. |
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 ]
Fired when the print job has completed.
Arguments:
| <Object> result | A json object that contains the url of the printed image:
{
url:printoutUrl
}
|
Code Snippet:
require([
"dojo/_base/connect", ...
], function(connect, ... ) {
connect.connect(printTask,'onComplete',function(result){
window.open(result.url);
})
...
});
Fired when an error occurs while executing the print task.
Arguments:
Fired when the print operation is complete. Should be used in favor of onComplete (Added at v3.5)
Event Properties:
| <String> url | The url to the printed resource |