require(["esri/tasks/PrintTask"], function(PrintTask) { /* code goes here */ });
Class: esri/tasks/PrintTask
Inheritance: PrintTask Task Accessor
Since: ArcGIS API for JavaScript 4.1

The PrintTask generates a printer-ready version of the map using an Export Web Map Task available with ArGIS Server 10.1 and later. This class is used when you want to have more granular control over the user interface, for example, if you want to provide users the ability to define what appears on the printed page.

Use PrintParameters to set the printing options of the task.

Known Limitations

  • PrintTask is not supported in SceneView.
  • VectorTileLayer printing requires ArcGIS Server 10.5.1 or later. When printing the VectorTileLayer, print task will use a client-side image for the VectorTileLayer in the printout. This has some limitations related to large size printing quality and a dependency on browser window height/width ratio.
See also:

Constructors

new PrintTask(properties)

Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String

The name of the class.

more details
more detailsAccessor
String

The mode for the print task execution.

more details
more detailsPrintTask
Object

The options to be used for data requests.

more details
more detailsTask
Number

The time interval in milliseconds between each job status request sent to an asynchronous GP task.

more details
more detailsPrintTask
String

The URL of the REST endpoint of the Export Web Map Task.

more details
more detailsPrintTask

Property Details

declaredClassStringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

modeString

The mode for the print task execution.

Known Values: async | sync

Default Value: sync

requestOptionsObject inherited

The options to be used for data requests. These options can also be controlled through the requestOptions method parameter.

updateDelayNumber

The time interval in milliseconds between each job status request sent to an asynchronous GP task.

Default Value: 1000

The URL of the REST endpoint of the Export Web Map Task.

Example:
var printTask = new PrintTask({
   url: printUrl
});

Method Overview

NameReturn TypeSummaryClass
Promise

Sends a request to the print service to create a print page using the options specified in the PrintParameters.

more details
more detailsPrintTask

Method Details

execute(params, requestOptions){Promise}

Sends a request to the print service to create a print page using the options specified in the PrintParameters.

Parameters:

Defines the printing options.

requestOptions Object
optional

Additional options to be used for the data request (will override requestOptions defined during construction).

Returns:
TypeDescription
PromiseWhen resolved, prints a layout of the map.
Example:
var printTask = new PrintTask({
   url: printUrl
});

var template = new PrintTemplate({
 format: "pdf",
 exportOptions: {
   dpi: 300
 },
 layout: "a4-portrait",
 layoutOptions: {
   titleText: "Warren Wilson College Trees",
   authorText: "Sam"
 }
});

var params = new PrintParameters({
 view: view,
 template: template
});

printTask.execute(params).then(printResult, printError);

API Reference search results

NameTypeModule

There were no match results from your search criteria.