Skip to content
import CustomTemplate from "@arcgis/core/widgets/Print/CustomTemplate.js";
Inheritance:
CustomTemplateAccessor
Since
ArcGIS Maps SDK for JavaScript 4.18

Defines the custom layout template options used by the Print widget and Print component to generate the print page. While custom templates can be published from ArcGIS Pro to a portal, custom layout templates are defined in a portal, where they can be added, removed, or edited as necessary without having to republish the print service. There are a limited number of options available for customization.

The main benefit of this class is that it allows developers to give a name to a preferred format and layout and if there should be a Legend present or not, in a reusable way. This is what the UI looks like in a portal:

Create-Print-Template

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
declaredClass
readonly inherited
description
readonly
id
readonly
label
readonly
layout
readonly
layoutItem
readonly
layoutOptions
readonly
pageUnits
readonly
state
readonly
"loaded" | "not-loaded" | "loading" | "error"
type
deprecated readonly
"browse-template" | "default-template" | "print-service-template" | null | undefined

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

description

readonly Property
Type
string | null | undefined

The template's description.

format

Property
Type
PrintFileFormat | null | undefined

The output format for the printed map.

id

readonly Property
Type
string
Since
ArcGIS Maps SDK for JavaScript 4.33

Unique id for the template.

label

readonly Property
Type
string | null | undefined

The text that appears inside the Select template button. This is the label for the template as defined in a portal.

layout

readonly Property
Type
PrintLayoutTemplate | null | undefined

The layout used for the print output. When the value is map-only or is empty, the output map does not contain any page layout surroundings (for example: legend, scale bar, and so forth). The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service.

Possible values are listed below:

ValueDescription
map-onlyMap does not contain any layout elements. Only the map image is printed.
a3-landscapeA3 Landscape
a3-portraitA3 Portrait
a4-landscapeA4 Landscape
a4-portraitA4 Portrait
letter-ansi-a-landscapeLetter ANSI A Landscape
letter-ansi-a-portraitLetter ANSI A Portrait
tabloid-ansi-b-landscapeTabloid ANSI B Landscape
tabloid-ansi-b-portraitTabloid ANSI B Portrait

layoutItem

readonly Property
Type
PortalItem | null | undefined

The portal item associated with layout (if any).

layoutOptions

readonly Property
Type
LayoutOptions | null | undefined

Defines the layout elements. It's an object with the following property:

layoutTemplateInfo

readonly Property
Type
LayoutTemplateInfo | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.33

Defines the layout template info for the layout item.

mapSurroundInfoOptions

readonly Property
Type
MapSurroundInfoOptions | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.33

This object returns settings for a legend, north arrow and scale bar (if any).

pageUnits

readonly Property
Type
Unit | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.33

The pageUnits from layoutTemplateInfo.

state

readonly Property
Type
"loaded" | "not-loaded" | "loading" | "error"
Since
ArcGIS Maps SDK for JavaScript 4.33

Loading state of the template.

Default value
"not-loaded"

type

deprecatedreadonly Property
Type
"browse-template" | "default-template" | "print-service-template" | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.33

The type of CustomTemplate.

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameters
ParameterTypeDescriptionRequired
json
any

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
any

Returns a new instance of this class.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.

Type definitions

LayoutOptions

Type definition

legend

Property
Type
boolean | null | undefined

Indicates whether the legend will be included in the print-out.

northArrow

Property
Type
boolean | null | undefined

Indicates whether the north arrow will be included in the print-out.

MapSurroundInfoOptions

Type definition

northArrow

Property
Type
Extract<MapSurroundInfo, { type: "cim-marker-north-arrow"; }>[]

MapSurroundInfo for north arrow.

scaleBar

Property
Type
Extract<MapSurroundInfo, { type: "cim-scale-line" | "cim-group-element"; }>[]

MapSurroundInfo for scale bar.

legend

Property
Type
Extract<MapSurroundInfo, { type: "cim-legend"; }>[]

MapSurroundInfo for legend.