Export map to PDF - graphics not appearing

Discussion created by sra_esri on Nov 11, 2013
Latest reply on Nov 17, 2013 by sra_esri
I'm having an issue with our ArcObjects code for exporting a map to PDF. There is a section of code that adds graphics on to the map (polygons, lines, text etc). This seems to work fine for the first map generated after the map service is started, but on subsequent prints the markup does not get displayed on the map. This code worked previously but no we've converted it to run as an SOE on ArcGIS Server.

The code in question:

            // IMap map, IGraphicElements graphicElements

            GraphicUtil.GetGraphicsContainer(map).DeleteAllElements(); // clear any previous markup

            _logger.Debug("Add graphic elements to container");
            IGraphicsContainer graphicsContainer = GetGraphicsContainer(map);
            for (int i = 0; i < graphicElements.Count; i++)
                IElement element = graphicElements.get_Element(i) as IElement;
                _logger.Debug("Adding geometry type: " + element.Geometry.GeometryType.ToString());
                graphicsContainer.AddElement(element, 0);

            ((IActiveView)map).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);


        public static IGraphicsContainer GetGraphicsContainer(IMap map)
            return (IGraphicsContainer)map;

If I take out the DeleteAllElements the markup stays on the map between requests but any new markup doesn't get added.
If I restart the map service, then it will add the markup on the next request, then not add anything after that.

In the ArcGIS Server logs I can see the following items which indicates nothing is being drawn, even though the graphic elements have been correctly added to the graphics container in the code (as far as I can tell)

INFO3 End of the graphics drawing.
INFO3 Graphic count: 0.
INFO3 Beginning of the graphics drawing.

Any ideas?