Automate printing of multiple maps w/ Print widget

1796
6
11-06-2020 06:54 AM
ErfanGoharian
New Contributor III

Hi all,

I need to create a new print widget, which does these (all together in one widget, or at least some of these):

1. Printing multiple maps, instead of one, where in each map a specific base map and sets of layers are used.

2. Changes the zoom extent for each print map.

3.User needs to upload a layer, e.g. project layer, which sometimes the length of the project is too long that we need to break the ma/player into different printing maps, how automatically we can split it into multiple prints at a certain extent (instead of zooming out to capture the whole layer)?

I know it seems a lot of work, but I appreciate it if someone can help me with this.

Thanks

0 Kudos
6 Replies
TanuHoque
Esri Regular Contributor

Hi Erfan Goharian‌,

Sorry I didn't get the complete pic of what you want. Is that possible for you to give us some screenshots or sketches?

thanks

0 Kudos
ErfanGoharian
New Contributor III

Hi, let me explain it more the first and second points (let's forget about the 3rd one for now):

Attached I show an example, where I, like always, print a map with the original basemap and a bunch of layers that are turned on. Then, I want to change the basemap and switch on and off other layers different from the first print and print it again, and finally, I want to print a map, let's say similar to the second print, but the basemap is changed again and it is zoomed in to a finer extent.

Clearly, I can do the whole thing manually by printing, then going and changing basemap, turning on/pff layers from layer list, and change the zoom. But how can I automate this process, such that when I click on print alll three PDFs are generated?

0 Kudos
TanuHoque
Esri Regular Contributor

Erfan Goharian‌,

this requires you to write an arcpy based print service solution that will:

  • generate the first pdf first
  • then modify visibility of some layers >> export that to another pdf
  • then zoom in to your desired scale >> export it to a 3rd pdf
  • finally, combine all 3 pdfs into a single pdf and return that multi page pdf back to the client app
0 Kudos
ErfanGoharian
New Contributor III

How does it understand which basemaps and layers should be turned on and off? e.g. the layers are hosted in ESRI map, even some layers will be uploaded by users in WebApp.

0 Kudos
TanuHoque
Esri Regular Contributor

Sorry for the delay. It has been a crazy month. In case you didn't have any solution yet (or for other users from future):


How does it understand which basemaps and layers should be turned on and off? e.g. the layers are hosted in ESRI map, even some layers will be uploaded by users in WebApp.

That is the logic you need to have in the arcpy script.

A fairly easy way to get started to write arcpy based print service is to take a look at the python source code behind the Export Web Map tool in ArcGIS Pro.

At a high level, you need to do 3 things in your code:

  1. call arcpy.mp.ConvertWebMapToArcGISProject(...) function to create an in-memory project & map out of the webmap_json gets passed from web client's print widget/task
  2. get the map or the layout
  3. export the map or the layout to a pdf

 

Here are some arcpy functions/classes that will help you change a map's basemap layer, setting layers visibility, add layers etc.

https://pro.arcgis.com/en/pro-app/arcpy/mapping/map-class.htm
https://pro.arcgis.com/en/pro-app/arcpy/mapping/layer-class.htm

Here is help on the ConvertWebMapToArcGISProject(...) function. It has some very useful samples too.
https://pro.arcgis.com/en/pro-app/arcpy/mapping/convertwebmaptoarcgisproject.htm

Also, check arcpy.mp.PDFDocumentXXXX(...) functions to find out who to open & append pages in a pdf file.

 

hope you will find this helpful.

0 Kudos
ErfanGoharian
New Contributor III

Any online help or code examples on this?

0 Kudos