PrintTask

AMD: require(["esri/tasks/PrintTask"], (PrintTask) => { /* code goes here */ });
ESM: import PrintTask from "@arcgis/core/tasks/PrintTask";
Class: esri/tasks/PrintTask
Inheritance: PrintTask Task Accessor
Since: ArcGIS API for JavaScript 4.1
Deprecated since version 4.20. Use print instead.

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.

For more information about printing with the MAP_ONLY layout, please see exportOptions.

Use PrintParameters to set the printing options of the task.

Known Limitations

See print for a detailed list of known limitations.

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.
Show inherited properties Hide inherited properties
Name Type Summary Class
Stringmore details

The name of the class.

more detailsAccessor
Stringmore details

The mode for the print task execution.

more detailsPrintTask
Numbermore details

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

more detailsPrintTask
Stringmore details

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

more detailsPrintTask

Property Details

declaredClass Stringreadonly inherited
Since: ArcGIS API for JavaScript 4.7

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

mode Stringreadonly

The mode for the print task execution.

Possible Values:"async"|"sync"

Default Value:sync
updateDelay Number

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

Default Value:1000
url String

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

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

Method Overview

Name Return Type Summary Class
Promise<PrintResponse>more details

Sends a request to the print service to create a printable static image of the map using the options specified in the PrintParameters.

more detailsPrintTask

Method Details

execute(params, requestOptions){Promise<PrintResponse>}

Sends a request to the print service to create a printable static image of the map using the options specified in the PrintParameters.

Parameters:

Defines the printing options.

requestOptions Object
optional

Additional options to be used for the data request.

Returns:
Type Description
Promise<PrintResponse> Resolves to an object containing the URL of the generated printout of the view.
Example:
let printTask = new PrintTask({
   url: printUrl
});

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

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

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

Type Definitions

PrintResponse

Represents the response of the execute() method.

Property:
url String

URL pointing to the location of the generated printout of the view.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.