You are here: > ESRI Forums > arcgis server forums > Thread Replies

ArcGIS Server Forums

ArcGIS Server .Net: Developing applications forum

problem with printing the graphics. help ne...   Michal Gasparovic Jun 17, 2009
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject problem with printing the graphics. help needed! 
Author Michal Gasparovic 
Date Jun 17, 2009 
Message I'm in really big need for help with this one.
How can I print the graphics that are the result of the queryFunctionality.Query, converted to graphics layer and the RenderOnClient set to true(RenderOnClient = true) ????
It simply ignores all drawn graphics.

I use the MapDrawUtil to Print all the resources. We have 2 in-memory graphics services (beside the other services in the map), in one I draw the element the user has drawn via adf javascript (converted the coordinates to adf geometry), in the second service I store the results of the query converted to FeatureGraphicsLayer... the code below will print the graphics only for the first service I've mentioned, but the second is completely ignored though it contains the graphics (!)

Thank you for all your help! 
 
public static System.Drawing.Bitmap GetImage(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map loInputMap, double lpImage_x, double lpImage_y) {
            List<GraphicsLayer> changedGraphicsLayers = new List<GraphicsLayer>();
            try
            {
                ArrayList loArrBitmaps = new ArrayList();
                ArrayList loArrimgAttr = new ArrayList();
                double ldImgheight = lpImage_y;//400
                double ldImgwidth = lpImage_x;//600

                MapDrawUtility mapUtil = new MapDrawUtility(loInputMap);
                mapUtil.GenerateImageOnException = false;
                mapUtil.PerformValidation = true;
                ESRI.ArcGIS.ADF.Web.MapImage mapImg = null;               

                //print graphics?                
                MapResourceManager resources = loInputMap.MapResourceManagerInstance;
                foreach (MapResourceItem mri in resources.ResourceItems)
                {
                    
                    MapResource graphics = mri.Resource as MapResource;
                    if (graphics != null)
                    {
                        foreach (GraphicsLayer layer in graphics.Graphics.Tables)
                        {
                            if (layer.RenderOnClient)
                            {
                                changedGraphicsLayers.Add(layer);
                                layer.RenderOnClient = false;
                            }
                        }
                    }
                }
                mapImg = mapUtil.Print(loInputMap.Extent, Convert.ToInt32(lpImage_x), Convert.ToInt32(lpImage_y), 96);                

                              
                return mapImg.GetImage();
            }
            catch (SystemException loEx)
            {
                return null;
            }
            finally {
                if (changedGraphicsLayers.Count != 0)
                {
                    // set the renderonclient property back to previous
                    foreach (GraphicsLayer layer in changedGraphicsLayers)
                    {
                        layer.RenderOnClient = true;
                    }
                }
            }
        }