AnsweredAssumed Answered

Arcobjects SDK C# - Export MXD to PNG

Question asked by n.faget.mobigis on Apr 18, 2016
Latest reply on Sep 29, 2016 by n.faget.mobigis

Hi everyone,


I have a problem with Arcobjects SDK C#. I want to export a MXD to PDF, AI and PNG.

The PDF and AI Export works fine but not the PNG Export.


When I export to PNG, I have this error : Exception de HRESULT : 0x80040334



My call :

IMapDocument pMapDoc = new MapDocument();

pMapDoc.Open(folderFileMXD + nameFile + ".mxd");

IActiveView m_ActiveView = pMapDoc.ActiveView;

ExportActiveViewParameterized(nameFile, m_ActiveView, 300, 1, "PNG", folderFilePNG, false);


My function :


   private static void ExportActiveViewParameterized(string fileName, IActiveView docActiveView, int iOutputResolution, int lResampleRatio, string ExportType, string sOutputDir, Boolean bClipToGraphicsExtent)




                IExport docExport;

                IPrintAndExport docPrintExport;

                IOutputRasterSettings RasterSettings;

                // The Export*Class() type initializes a new export class of the desired type.

                if (ExportType == "PDF")


                    docExport = new ExportPDFClass();


                else if (ExportType == "AI")


                     docExport = new ExportAIClass();


                else if (ExportType == "PNG")


                    docExport = new ExportPNGClass();                   




                     ExportType = "EMF";

                    docExport = new ExportEMFClass();


                docPrintExport = new PrintAndExportClass();

                docExport.ExportFileName = sOutputDir + fileName + "." + docExport.Filter.Split('.')[1].Split('|')[0].Split(')')[0];

                //// check if export is vector or raster

                if (docExport is IOutputRasterSettings)


                    // for vector formats, assign the desired ResampleRatio to control drawing of raster layers at export time  

                    RasterSettings = (IOutputRasterSettings)docExport;

                    RasterSettings.ResampleRatio = (int)lResampleRatio;


                docPrintExport.Export(docActiveView, docExport, 300, bClipToGraphicsExtent, null);            


            catch (Exception e)








Do you have an idea of the problem ?


Thanks in advance