Printing with customizable templates

04-16-2015 10:04 AM
New Contributor

I've tried everything I could think of with this and have gotten very close to getting what I want but have run into several different problems. When I've used a different method to get around the problems I've just encountered others and I need a sanity check on my approach to the problem and to see if it's even possible.

I want to print maps from my web application built with the ArcGIS Javascript API.

The requirements are:

1. need to show only legend elements that are within the visible extent of the printed map. For instance, if I have a feature layer that uses a unique value renderer I only want to show the legend items for the values present on the map.


2. I want to be able to customize picture elements in the print template - to replace a logo for instance.

3. It would be nice if it was relatively fast or at least about as fast as the out of the box printing services. In my experience, this is about 3-6 seconds.

I tried writing a simple python script to replace picture elements.

LogoName = arcpy.GetParameterAsText(3)

if LogoName == '#' or not LogoName:

    LogoName = 'default-logo.png'

Logo = r'c:\GIS_Data\Logos\{}'.format(LogoName)

that works fine and along with arcpy.mapping.ExportToPDF or ExportToPNG it lets me convert a webmap to a printable template with custom logos.

This wasn't enough to get the legend behavior I wanted however. If a Marsh/Bog was within the extent of the map (see picture above) then it would show all wetland elements in the legend. I was able to solve this by creating a staged template that includes all the layers in the web map service (as detailed in this tutorial: ). This gives me everything I want but requires that I create a separate staged template for each map service. We have many map services and would need to keep the templates in sync with the web map services. Doing this for a dozen map services is a pain, doing it for hundreds is not feasible.

So I decided to do this in .NET ArcObjects. I was able to get it working but the Export method from the PrintAndExportClass takes 2 minutes to run within an SOE. If I create a console application it only takes a few seconds so I think it might have something to do with running it from within the SOE but I can't figure out what would cause such a slow down. I would prefer if it just broke within the SOE but it still runs - just takes forever.

I'd like a sanity check on the best way to approach this problem. It seems simple enough - replace a picture element, allow a single template to handle many map services, only include legend items actually present within the extent and not take 2 minutes to run.

What classes and methods within arcobjects should I be using to run a print service that handles these? Preferably it would run within an SOE but If self-hosting a console application in IIS Is faster or better can do that too.

Message was edited by: Ryan Muller - fixed an unclear pargraph

Tags (1)
0 Kudos
0 Replies