Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: Print

require(["esri/dijit/Print"], function(Print) { /* code goes here */ });

Description

(Added at v2.6)
The Print widget simplifies the process of printing a map using a default or user-defined layout. The Print widget displays a simple button or a button combined with a dropdown list of user-defined layouts. After clicking the print button, a hyperlink to the print page appears in place of the button. If you need more fine-grained control over printing view the PrintTask class.

Note:
  • The Print widget requires an ArcGIS Server 10.1 Export Web Map Task.
  • The print server does not directly print SVG symbols. Rather, they are converted to PictureMarkerSymbols for display.
  • Make certain that any resources to be printed are accessible by the print server. For example, if printing a map containing PictureMarkerSymbols, the URL to these symbols must be accessible to the print server for it to work properly.

Samples

Search for samples that use this class.

Constructors

NameSummary
new Print(params, srcNodeRef)Creates a new Print widget.

CSS

esri/dijit/Print | Download source

NameDescription
esriPrintDefine the styles for the print widget's parent div. Can be used to modify the padding, background etc.
esriPrintButtonDefine the style of the print button. Commonly used to set the font or color.

.esriPrintButton{

  color:#4A777A;

}

esriPrintoutDefine the style for the print image hyperlink.
.esriPrintout{
  color:#3D5229;
  text-decoration:none;
}

Methods

NameReturn typeSummary
destroy()NoneDestroys the print widget.
hide()NoneHide the print widget.
printMap(template)NoneUser can call this function so that it programatically print the map.
show()NoneSet the print widget's visibility to true.
startup()NoneFinalizes the creation of the print widget.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
error
{
  error: <Error>
}
Fired when an error occurs during the print request.
print-complete
{
  value: <Object>
}
Fired when the print job has succeeded.
print-startFired when the request is sent to the print service.
Constructor Details

new Print(params, srcNodeRef)

Creates a new Print widget.
Parameters:
<Object> params Required Parameters for the print widget. See the options table below for details on the parameters.
<Node | String> srcNodeRef Required HTML element where the print widget button and drop down list will be rendered.
params properties:
<Boolean> async Optional Set to true if the print service is an asynchronous geoprocessing service.
<Object> extraParameters Optional Additional parameters for the print service. When an arcpy script is published as a custom print service there may be additional parameters associated with the print service. To determine the extra parameters visit its ArcGIS REST Services Directory page for the custom print service.
<Map> map Optional The map to print.
<PrintTemplate[]> templates Optional An optional array of user-defined templates. If an array of templates is not specified or the array only has one item the Print widget will display as a button. If the template array contains more than one template the available templates are displayed in a drop-down list.
templates: [{
  label: "Map",
  format: "PDF",
  layout: "MAP_ONLY",
  exportOptions: {
    width: 500,
    height: 400,
    dpi: 96
  }
}, {
  label: "Layout",
  format: "PDF",
  layout: "A4 Portrait",
  layoutOptions: {
    titleText: "My Print",
    authorText: "esri",
    copyrightText: "My Company",
    scalebarUnit: "Miles",
  }
}]
<String> url Optional The url to an export web map task. Requires ArcGIS Server 10.1
Sample:
require([
  "esri/map", "esri/dijit/Print", "dojo/dom"... 
], function(Map, Print, dom, ... ) {
  var map = new Map( ... );
  var printer = new Print({
    map: map,
    url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
  }, dom.byId("printButton"));
  ...
});
Method Details

destroy()

Destroys the print widget. Call destroy() when the widget is no longer needed by the application.
Sample:
printer.destroy();

hide()

Hide the print widget.

printMap(template)

User can call this function so that it programatically print the map.
Parameters:
<PrintTemplate> template Required Print template.

show()

Set the print widget's visibility to true.

startup()

Finalizes the creation of the print widget. Call startup() after creating the widget when you are ready for user interaction.
Sample:
require([
  "esri/map", "esri/dijit/Print", "dojo/dom", ... 
], function(Map, Print, dom, ... ) {
  var map = new Map( ... );
  var printer = new Print({
    map: map,
    url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task"
  }, dom.byId("printButton"));
  
  printer.startup();
  ...
});
Event Details
[ On Style Events | Connect Style Event ]

error

Fired when an error occurs during the print request. (Added at v3.6)
Event Object Properties:
<Error> error Error message returned in a JavaScript error object.

print-complete

Fired when the print job has succeeded. (Added at v3.6)
Event Object Properties:
<Object> value An object that contains the url of the printed image: {url:the-print-url}.
Sample:
require([
 ... 
], function( ... ) {
  printer.on('print-complete',function(evt){
    console.log('The url to the print image is : ' + evt.result.url);
  });
  ...
});

print-start

Fired when the request is sent to the print service. (Added at v3.6)
Sample:
require([
 ... 
], function( ... ) {
  printer.on('print-start',function(){
    console.log('The print operation has started');
  });
  ...
});
Show Modal