There are several ways to generate a printable document from a web application. By default, ArcGIS Server includes a geoprocessing service called PrintingTools. Web applications invoke the PrintingTools service and get a printable document in return. You can also create a custom print service using your own layouts rather than those in the default PrintingTools service. For advanced printing, you can use a Python script to convert the web map into an ArcMap document (MXD), and in turn export the MXD to a variety of formats for printing.
Printing can be configured for Portal for ArcGIS, web app templates, Web AppBuilder for ArcGIS, and for applications created using the ArcGIS web APIs. See Configure the portal to print maps in the Portal Administrator Guide for more information about providing your portal, including any applications created with Web AppBuilder or web app templates, with printing capabilities.
The PrintingTools service
PrintingTools is a preconfigured service in the Utilities folder that creates a printable document using one of a set of predefined map layouts. These include basic designs using 8.5 by 11 inch, 11 by 17 inch, A3, and A4 paper sizes in both portrait and landscape orientations. Each layout contains a north arrow, scale bar and ratio, legend, date, and title. The supported output formats from the PrintingTools service are PDF (georeferenced), PNG32, PNG8, JPG, GIF, EPS, SVG, and SVGZ.
The PrintingTools service is stopped by default. You must use ArcGIS Desktop or ArcGIS Server Manager to start the service if you want to support printing workflows. Once the PrintingTools service has started, you can access it using a URL with the following format: https://webadaptor.domain.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task.
The ArcGIS web APIs offer widgets that can communicate with the PrintingTools service to get a printable map. You provide the URL of the PrintingTools service and the widgets do the rest of the work. For more information on using the PrintingTools service with your Portal for ArcGIS deployment, see Configure the portal to print maps.
When your map service is cached, the PrintingTools service may use a resolution that is too low (for example, 96 DPI) for large format or high quality printing. To print at higher resolutions, it is recommended that you enable dynamic layers on your cached map service. This allows the print service to obtain map images (through an export map request) at the desired resolution (for example, 300 DPI) instead of the lower resolution tiles. To learn more, see About dynamic layers.
Beginning at 10.4, a new task is available in the PrintingTools service: Get Layout Templates Info. The task provides the size of the layout page and the size of the active data frame. It also shows whether the following layout elements are available:
- Title text
- Copyright text
- Author text
- Custom text elements
You can also add this task to custom print services. For instructions, see Tutorial: Publishing additional services for printing.
Custom print services
If you want to use your own map layouts, you can publish your own service for web map printing similar to PrintingTools. You configure this service to reference your own folder of ArcMap documents (MXDs) that you've prepared with various map layouts.
You can find instructions for publishing your own service for web printing (and pointing it at your own layouts folder) in Tutorial: Publishing additional services for printing. The tutorial also explains what to do if you later decide you want to update your layouts. Your update approach will vary based on whether or not you registered your layouts folder with the server before publishing, and the tutorial contains instructions for both scenarios.
Note that there are additional considerations in the tutorial for publishing and consuming custom print services in Portal for ArcGIS. The custom print service must be published as a synchronous geoprocessing service and the URL for the print service must use HTTPS for the portal to accept it as the portal's print service. For more information on using a custom print service with your Portal for ArcGIS deployment, see Configure the portal to print maps.
Custom print services can print layouts that use multiple data frames. The service only replaces the map in the active data frame; however, if the data frames have some relationship between them, such as an extent rectangle, that relationship is honored by the print service. For example, suppose you have a layout with two data frames: a main map and an overview map. The overview map includes an extent rectangle showing the current extent of the main map. Before using this layout with your custom print service, you need to ensure that the main map data frame is the active data frame. When a web user requests a map with your layout, the main map will show the current web map view, and the overview map's extent rectangle will display the extent of the main map as expected
Whether you use PrintingTools or a custom print service, the legends in your printed output will behave similarly. When printing feature services, the legend in the printed document will only include legend entries for the features found in the map extent, whereas legends for other service types will include all of the legend entries for the features regardless of the map extent.
Advanced printing using Python
For advanced printing scenarios, you do not use PrintingTools at all; rather, you can use the ConvertWebMapToMapDocument function in the Python arcpy.mapping module included with ArcGIS. When the document is converted, the full web map exists in the map document. The map document can then be further modified before finally being printed or exported to a common format such as PDF.
The ConvertWebMapToMapDocument function is commonly used to replace service layers with local vector data, create map books, control the appearance of the legend, and export different formats using advanced options.
To make your Python script available to a web application, you can expose the script through an ArcGIS Server geoprocessing service. See Advanced printing for web maps to learn more.