import arcpy mxd = arcpy.mapping.MapDocument(r"C:\#workspace\TileExport.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] Field = "NAME" for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum pageName = mxd.dataDrivenPages.pageRow.getValue(Field) arcpy.mapping.ExportToPNG(mxd, r"C:\#workspace\Tile_" + str(pageName) + ".png", df, df_export_width=5000, df_export_height=5000, resolution=254, world_file=True, color_mode="8-BIT_PALETTE", background_color="255,255,255", transparent_color="255,255,255") del df del mxd
'Time to export the map pAnimProcessor.Message = "Exporting to PNG file..." 'Create variables for map and extent 'Set the current map and TELL IT TO LOOK AT THE LAYOUT VIEW! pMxDoc = m_application.Document pActiveView = pMxDoc.PageLayout 'Create export object and set the resolution Dim pExport As IExport pExport = New ExportPNG 'Get display bounds and graphics content Dim DisplayBounds As tagRECT If TypeOf pActiveView Is IPageLayout Then DisplayBounds = pActiveView.ExportFrame Else DisplayBounds.left = 0 DisplayBounds.top = 0 DisplayBounds.right = pActiveView.ScreenDisplay.DisplayTransformation.DeviceFrame.right DisplayBounds.bottom = pActiveView.ScreenDisplay.DisplayTransformation.DeviceFrame.bottom End If 'get the export rectangle Dim exportRect As tagRECT Dim outputresolution As Integer Dim screenresolution As Integer outputresolution = 300 'desired resolution screenresolution = 96 ' default screen resolution pExport.Resolution = outputresolution 'The ExportFrame property gives us the dimensions appropriate for an export at screen resolution. ' Because we are exporting at a higher resolution (more pixels), we must multiply each dimesion ' by the ratio of OutputResolution to ScreenResolution. Instead of assigning the entire ' ExportFrame directly to the exportRECT, let's bring the values across one at a time and multiply ' the dimensions. With exportRect .bottom = Convert.ToInt32(DisplayBounds.bottom * (outputResolution / screenResolution)) .left = Convert.ToInt32(DisplayBounds.left * (outputResolution / screenResolution)) .top = Convert.ToInt32(DisplayBounds.top * (outputResolution / screenResolution)) .right = Convert.ToInt32(DisplayBounds.right * (outputResolution / screenResolution)) End With 'Set the size and extent of the export Dim pPixelBoundsEnv As IEnvelope pPixelBoundsEnv = New Envelope pPixelBoundsEnv.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom) pExport.PixelBounds = pPixelBoundsEnv 'Set file name and export map Dim hDC As Long pExport.ExportFileName = OutputPath & "\" & [INSERT NAME HERE] & ".png" hDC = pExport.StartExporting pActiveView.Output(hDC, pExport.Resolution, exportRect, Nothing, Nothing) pExport.FinishExporting() pExport.Cleanup()