require(["esri/tasks/PrintTemplate"], function(PrintTemplate) { /* code goes here */ });
Description
(Added at v2.6)
Define the layout template options used by the PrintTask and Print widget to generate the print page.
Samples
Search for
samples that use this class.
Constructors
Properties
Constructor Details
Creates a new PrintTemplate object.
Sample:
require([
"esri/tasks/PrintTemplate", ...
], function(PrintTemplate, ... ) {
var template = new PrintTemplate();
...
});
Property Details
Define the map width, height and dpi. Required when the
layoutTemplate
is set to 'MAP_ONLY'. exportOptions is an object with the following structure:
{
<Number> width,
<Number> height,
<Number> dpi
}
Sample: template.exportOptions = {
width: 500,
height: 400,
dpi: 96
};
When true, the feature's attributes are included in feature collection layers even when they are not needed for rendering. By default they are removed to reduce the request size. Only applicable to custom print services which use the feature attributes, for example to display a table of features and their attributes. (Added at v3.24)
Default value: false
The print output format.
Known values: pdf | png32 | png8 | jpg | gif | eps | svg | svgz
Sample: template.format = "PDF";
The text that appears on the Print widget's print button.
The layout used for the print output. The print service provides the following out-of-the-box templates:
- MAP_ONLY
- A3 Landscape
- A3 Portrait
- A4 Landscape
- A4 Portrait
- Letter ANSI A Landscape
- Letter ANSI A Portrait
- Tabloid ANSI B Landscape
- Tabloid ANSI B Portrait
The server administrator can add additional templates to the print service.
Sample:
template.layout = "MAP_ONLY";
Define the layout elements. Is an object with the following properties:
titleText |
The text used for the map title if the specified layout contains a title text element. |
authorText |
The text used for the author if the specified layout contains an author text element. |
copyrightText |
The text used for the copyright if the specified layout contains an copyright text element. |
scalebarUnit |
The units used for the scalebar. Valid values are 'Miles' | 'Kilometers' | 'Meters' | 'Feet'. Default is "Miles". |
legendLayers <esri.tasks.LegendLayer[]> |
An array of LegendLayer containing the id's of the layers that will be included in the legend. If legendLayers is not specified, all operational layers (non-tiled layers) will be present in the legend. To specify that no layers will be included in the legend set legendLayer to an empty array. |
customTextElements <Object[]> |
Updated the text for a TextElement, that is not DynamicText, on the page layout. Values must be strings. |
The optional map scale of the printed map. Only applies when preserveScale is true
. If outScale is less than 1, then the printed map will use the scale of the input map. (Added at v3.11)
Sample: template.outScale = 24000;
Define whether the printed map should preserve map scale or map extent. If true
, the printed map will use the outScale
property or default to the scale of the input map. If false
, then the printed map will use the same extent as the input map and thus scale might change.
Default value: false
Sample: template.preserveScale = true;
When false, attribution is not displayed on the printout. This only applies when the
layout value is MAP_ONLY. When true, it will honor the showAttribution property of the map object. Reference our policies on
Licensing & Attribution for specific attribution requirements.
(Added at v3.3) Known values: true | false
Default value: true
Indicates whether visible
LabelLayers in the map are displayed or not.
(Added at v3.14) Default value: true