Skip To Content

Advanced printing for web maps

The PrintingTools service and its client print widgets in the ArcGIS web APIs are intended for basic printing. For printing workflows in which the web map must be modified or exported using advanced options, use ConvertWebMapToArcGISProject for ArcGIS Pro.

Web map printing in ArcGIS hinges on the ability of the web map to be represented as JSON. The ExportWebMap specification defines how a web map can be structured as JSON with extent and layer information for printing. The ArcGIS web APIs can read your current web map and make the JSON for you. In a simple printing scenario, the ArcGIS Server PrintingTools service reads the JSON and returns a map image that can be printed.

In advanced printing scenarios, the web map JSON does not have to be sent to the PrintingTools service. Instead, you can convert the JSON to an ArcGIS Pro project (.aprx).

Converting a web map to an ArcGIS Pro project using Python

To convert a web map JSON to an ArcGIS Pro project (.aprx), use the ConvertWebMapToArcGISProject function. Once the web map is converted, the full state of the web map exists in the project. You can then modify the web map further before printing, or export it using another Python function. You can also add the map to a map book before printing it or switch out some of the service layers in the map with your own vector layers.

For more detailed discussion, scenarios, and code samples, see Web map printing with arcpy.mp, which explains how to author staged layout templates, author a Python script for a web map, and create web tools and web apps.

ArcGIS Pro 3.1 installation comes with a toolbox named PrintingTools.atbx containing preconfigured Export Web Map and Get Layout Templates Info script tools to simplify the process of writing ArcPy-based print services. The toolbox is located in the <ArcGIS Pro installation location>\Resources\ArcToolBox\Templates\PrintService directory.

Calling your scripts from the web

Once you've written an arcpy script for printing, ArcGIS Enterprise offers geoprocessing services that allow you to expose your scripts, tools, and models as web services. This makes them callable from the ArcGIS web APIs.

You can choose to encapsulate your Python printing script in a geoprocessing script tool. Do a test run of your tool and then publish the result as an ArcGIS Enterprise geoprocessing service.

When developing this type of geoprocessing script tool, ensure that it exposes the same parameters as the out-of-the-box PrintingTools service or a subset thereof. The input JSON parameter is the minimum required parameter needed. If you design your service in this way, the printing widgets from ArcGIS Web AppBuilder and printing tasks in the ArcGIS web mapping APIs and web viewers can use your service without any custom coding.