print

AMD: require(["esri/rest/print"], (print) => { /* code goes here */ });
ESM: import * as print from "@arcgis/core/rest/print.js";
Object: esri/rest/print
Since: ArcGIS Maps SDK for JavaScript 4.20

The print module provides an executePrint method that 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.

Known Limitations

No support

  • There is no current support for printing with any Printing Service published with ArcMap.
  • There is no current support for printing SceneViews. Instead, see SceneView.takeScreenshot().
  • There is no current support for printing ImageryLayers when a pixelFilter is defined.
  • There is no current support for printing renderers generated from univariateColorSize.createContinuousRenderer() with an above-and-below theme.
  • There is no current support for printing legend items for layers that are sent as a client-side image in the printout.
  • There is no current support for printing rotated symbols and labels when the map is rotated, and layers are sent as a client-side image in the printout.
  • There is no current support for printing features when using a renderer with above-and-below theme.
  • There is no current support for printing the drawing order of layers configured with the orderBy property.
  • There is no current support for printing GroupLayers with blending or effects. Instead, see MapView.takeScreenshot().
  • There is no current support for printing effects when a blendMode is applied to a layer.
  • There is no current support for printing layers with the following blendModes: "average", "destination-atop", "destination-in", "destination-out", "destination-over", "invert", "lighter", "minus", "plus", "reflect", "source-atop", "source-in", "source-out", "vivid-light", "XOR".

Versioned support

  • Labels currently cannot be printed as part of a FeatureLayer with ArcGIS Server 10.5.1.
  • ImageryLayer cannot be printed with ArcGIS Server 10.5.1 or earlier.
  • VectorTileLayer printing requires ArcGIS Server 10.5.1 or later.
  • Printing layers rendered with the DotDensityRenderer will create a client-side image of the layer in the printout with ArcGIS Server 10.8.0 or earlier.
  • Printing layers using clustering will create a client-side image of the layer in the printout with GeoJSONLayer and/or ArcGIS Server 10.9.0 or earlier.
  • For printing secure VectorTileLayers with ArcGIS Server 10.5.1 or 10.6.0, or for printing VectorTileLayers with ArcGIS Server 10.5.1, the print will create a client-side image for the VectorTileLayer to use in the printout. This has some limitations related to large size printing quality and a dependency on browser window height/width ratio.
  • Printing the background color of a MapView or WebMap requires ArcGIS Server 10.9.0 or later.
  • Printing layers with non-standard URLs (e.g. no MapServer, FeatureServer, or ImageServer in the URL) requires ArcGIS Server 10.9.1 or later.
  • Printing layers with supported blendModes requires ArcGIS Server 10.9.1 or later. This is the list of currently supported types: "color-burn", "color-dodge", "color", "darken", "difference", "exclusion", "hard-light", "hue", "lighten", "luminosity", "multiply", "normal", "overlay", "saturation", "screen", "soft-light".
  • Printing highlighted features with SimpleFillSymbol with FeatureLayers requires ArcGIS Server 11.4.0 or higher.
  • For printing CatalogLayer the catalog footprint is sent as a feature collection if the ArcGIS Server version is less than 11.3.1. Otherwise, it's sent as a CatalogLayer with the dynamicGroupLayer visibility set to false. The other layers from the CatalogLayer are sent separately.

Behavior notes

  • Printing layers using effects will create a client-side image of the layer in the printout.
  • Printing layers using binning will create a client-side image of the layer in the printout.
  • Printing layers using pie-chart renderer will create a client-side image of the layer in the printout.
  • Printing layers using highlighted features is only supported for FeatureLayer. For other layer types, see MapView.takeScreenshot().
  • Legends will not print if there is not enough space in the template for both the map and the legend.
  • The print server does not directly print SVG symbols. Rather, they are converted to PictureMarkerSymbols for display.
  • Make certain that any resources to be printed are accessible by the print server. For example, if printing a map containing PictureMarkerSymbols, the URL to these symbols must be accessible to the print server for it to work properly.
  • Currently, charts can only be printed when published as part of a FeatureLayer, and with ArcGIS Server version 11.2 or later.
  • For Print widget only: if the application and the print service are on the same origin, the name of the downloadable file can be customized with the fileName or title properties. If not, the name of the downloadable file will be generated by the ArcGIS Enterprise that hosts the print service.
See also

Method Overview

Name Return Type Summary Object
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.

print
Promise<String>

Request the mode for the print request service.

print

Method Details

execute

Method
execute(url, 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
url String

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

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
require([
 "esri/rest/print",
 "esri/rest/support/PrintTemplate",
 "esri/rest/support/PrintParameters"
], function(print, PrintTemplate, PrintParameters) {

  // url to the print service
  const url = "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";

  const template = new PrintTemplate({
    format: "pdf",
    exportOptions: {
      dpi: 300
    },
    layout: "a4-portrait",
    layoutOptions: {
      titleText: "Gillette Stadium",
      authorText: "Thomas B."
    }
  });

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

  // print when this function is called
  function executePrint() {
    print.execute(url, params).then(printResult).catch(printError);
  }

  function printResult(result) {
    console.log(result.url);
    window.open(result.url);
  }

  function printError(err) {
    console.log("Something broke: ", err);
  }
});

getMode

Method
getMode(url){Promise<String>}

Request the mode for the print request service.

Parameter
url String

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

Returns
Type Description
Promise<String> Returns the mode for the print request execution, either "sync" or "async".

Type Definitions

PrintResponse

Type Definition
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.