Hide Table of Contents
esri
Map
toolbars
Class: PrintTemplate
[ AMD Module Require | Legacy Module Require ]

Module Require

require(["esri/tasks/PrintTemplate", ... ], function(PrintTemplate, ... ){ ... });

Description

Class added 2.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.

Class hierarchy

esri.tasks.PrintTemplate

Constructors

ConstructorDescription
new PrintTemplate()Creates a new PrintTemplate object.

Properties

PropertyTypeDescription
exportOptionsObjectDefine the map width, height and dpi. Required when the layoutTemplate is set to 'MAP_ONLY'.
formatStringThe print output format.
labelStringThe text that appears on the PrintWidget's print button.
layoutStringThe layout used for the print output.
layoutOptionsObjectDefine the layout elements.
preserveScaleBooleanDefine whether the printed map will preserve the map scale or the map extent.
showAttributionBooleanWhen false, attribution is not displayed on the printout. When true, it will honor the showAttribution property of the map object. 
Constructor Details

new PrintTemplate()

Creates a new PrintTemplate object.
Code Snippet:
require([
  "esri/tasks/PrintTemplate", ... 
], function(PrintTemplate, ... ) {
  var template = new PrintTemplate();
  ...
});
Property Details

<Object> exportOptions

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
  }
Code Snippet:
template.exportOptions = {
  width: 500,
  height: 400,
  dpi: 96
};

<String> format

The print output format.
Known Values: pdf | png32 | png8 | jpg | gif | eps | svg | svgz
Code Snippet:
  template.format = "PDF";

<String> label

The text that appears on the PrintWidget's print button.

<String> layout

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.
Code Snippet:
  template.layout = "MAP_ONLY";

<Object> layoutOptions

Define the layout elements using 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'
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 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.


<Boolean> preserveScale

Define whether the printed map will preserve the map scale or the map extent. Only one of these properties can be preserved to produce a high-resolution map for printing. If preserveScale is set to true, the map displayed in the print window will match the current scale of the map in the application. If preserveScale is false, the current extent of the map in the application displays in the printed map but the scale may change. The default value is true.
Code Snippet:
  template.preserveScale = false;

<Boolean> showAttribution

When false, attribution is not displayed on the printout. When true, it will honor the showAttribution property of the map object.  (Added at v3.3)