UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

136 lines (134 loc) • 13.1 kB
/** * The print module provides an `executePrint` method that generates a printer-ready version of the map using an * [Export Web Map Task](https://developers.arcgis.com/rest/services-reference/export-web-map-task.htm) * 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 * [PrintTemplate.exportOptions](https://developers.arcgis.com/javascript/latest/references/core/rest/support/PrintTemplate/#exportOptions). * * Use [PrintParameters](https://developers.arcgis.com/javascript/latest/references/core/rest/support/PrintParameters/) to set the printing options. * * > [!WARNING] * > * > **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](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). Instead, see [SceneView.takeScreenshot()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#takeScreenshot). * > There is no current support for printing [ImageryLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/) when a [ImageryLayer.pixelFilter](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/#pixelFilter) * > is defined. * > There is no current support for printing renderers generated from [createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/renderers/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 [GroupLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/GroupLayer/) with blending or effects. Instead, see [MapView.takeScreenshot()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#takeScreenshot). * > There is no current support for printing [effects](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#effect) when a [FeatureLayer.blendMode](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#blendMode) is applied to a layer. * > There is no current support for printing layers with the following [blendModes](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#blendMode): * > `"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](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) currently cannot be printed as part of a FeatureLayer with ArcGIS Server 10.5.1. * > [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/) cannot be printed with ArcGIS Server 10.5.1 or earlier. * > [VectorTileLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/VectorTileLayer/) printing requires ArcGIS Server 10.5.1 or later. * > Printing layers rendered with the [DotDensityRenderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#featureReduction) will create a client-side image of the layer in the printout with [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/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](https://developers.arcgis.com/javascript/latest/references/core/rest/print/) will create a client-side image for the VectorTileLayer to use in the printout. * > Printing [WFSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/) will create a client-side image of the layer in the printout with ArcGIS Server 11.4.1 or earlier. * > This has some limitations related to large size printing quality and a dependency on browser window height/width ratio. * > Printing the drawing order of layers configured with the `orderBy` property is supported with ArcGIS Server 11.5.0 or later. * > Printing the background color of a [MapView.background](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#background) or [WebMap](https://developers.arcgis.com/javascript/latest/references/core/webmap/background/ColorBackground/) 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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/) 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](https://developers.arcgis.com/javascript/latest/references/core/symbols/SimpleFillSymbol/) with [FeatureLayers](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#highlight) requires ArcGIS Server 11.4.0 or higher. * > For printing [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#effect) will create a client-side image of the layer in the printout. * > Printing layers using [binning](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FeatureReductionBinning/) will create a client-side image of the layer in the printout. * > Printing layers using [pie-chart renderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/PieChartRenderer/) will create a client-side image of the layer in the printout. * > Printing layers using [TrackInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TrackInfo/) and/or [TrackInfo.trackLines](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TrackInfo/#trackLines) will create a client-side image of the layer in the printout. * > Printing [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/) geometries may result in a different output based on the algorithms used to compute labels on the print server versus that of the ArcGIS Maps SDK for JavaScript. * > Printing layers using [highlighted features](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLayerView/#highlight) is only supported for [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). For other layer types, see [MapView.takeScreenshot()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#takeScreenshot). * > Printing layers using [spike renderer](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/renderers/size/#updateRendererWithSpike) will not apply the spike renderer to the printed legend. * > Legends will print if there is enough space in the template for both the map and the legend. * > The print server does not directly print [SVG](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/symbol) symbols. Rather, they are converted to [PictureMarkerSymbols](https://developers.arcgis.com/javascript/latest/references/core/symbols/PictureMarkerSymbol/) for display. * > Make certain that any resources to be printed are accessible by the print server. For example, if printing a map containing [PictureMarkerSymbols](https://developers.arcgis.com/javascript/latest/references/core/symbols/PictureMarkerSymbol/), * > 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](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/), and with ArcGIS Server version 11.2 or later. * > For [Print](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-print/) component only: if the application and the print service are on the same origin, the name of the downloadable file can be customized with the [TemplateOptions.fileName](https://developers.arcgis.com/javascript/latest/references/core/widgets/Print/TemplateOptions/#fileName) * > or [TemplateOptions.title](https://developers.arcgis.com/javascript/latest/references/core/widgets/Print/TemplateOptions/#title) properties. If not, the name of the downloadable file will be generated by the ArcGIS Enterprise that hosts the print service. * * @since 4.20 * @see [Print widget](https://developers.arcgis.com/javascript/latest/references/core/widgets/Print/) - _Deprecated since 4.33. Use the [Print component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-print/) instead._ * @see [Print component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-print/) * @see [PrintTemplate](https://developers.arcgis.com/javascript/latest/references/core/rest/support/PrintTemplate/) */ import type PrintParameters from "./support/PrintParameters.js"; import type { RequestOptions } from "../request/types.js"; import type { PrintResponse } from "./types.js"; /** * Sends a request to the print service to create a printable static image of the map using the options specified in * the [PrintParameters](https://developers.arcgis.com/javascript/latest/references/core/rest/support/PrintParameters/). * * @param url - The URL of the REST endpoint of the Export Web Map Task. * @param params - Defines the printing options. * @param requestOptions - Additional [options](https://developers.arcgis.com/javascript/latest/references/core/request/#request) to be used for the data request. * @returns Resolves to an object containing the URL of the generated printout of the view. * @example * const [print, PrintTemplate, PrintParameters] = await $arcgis.import([ * "@arcgis/core/rest/print.js", * "@arcgis/core/rest/support/PrintTemplate.js", * "@arcgis/core/rest/support/PrintParameters.js" * ]); * * // 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); * } */ export function execute(url: string, params: PrintParameters, requestOptions?: RequestOptions): Promise<PrintResponse>; /** * Request the mode for the print request service. * * @param url - The URL of the REST endpoint of the Export Web Map Task. * @returns Returns the mode for the print request execution, either "sync" or "async". */ export function getMode(url: string): Promise<string>;