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
Properties
| exportOptions | Object | Define the map width, height and dpi. Required when the layoutTemplate is set to 'MAP_ONLY'. |
| format | String | The print output format. |
| label | String | The text that appears on the PrintWidget's print button. |
| layout | String | The layout used for the print output. |
| layoutOptions | Object | Define the layout elements. |
| preserveScale | Boolean | Define whether the printed map will preserve the map scale or the map extent. |
| showAttribution | Boolean | When false, attribution is not displayed on the printout. When true, it will honor the showAttribution property of the map object. |
Constructor Details
Creates a new PrintTemplate object.
Code Snippet:
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
}
Code Snippet:
template.exportOptions = {
width: 500,
height: 400,
dpi: 96
};
The print output format.
Known Values: pdf | png32 | png8 | jpg | gif | eps | svg | svgz
Code Snippet:
template.format = "PDF";
The text that appears on the PrintWidget'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.
Code Snippet:
template.layout = "MAP_ONLY";
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. |
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)