Automatically export layout geotiff...with printer extents

Discussion created by clareau on Apr 8, 2011
Latest reply on Apr 17, 2011 by Hydronaut
I have a Viusal Basic 2008 program that updates and mxd file with new layers then exports a layout geotiff.  My problem is that the geotiff that is exported is bigger than the printer extents that are saved off in the mxd.  The following is the code that I use to export my geotiff:

Public Sub OutputToTIFF9DataView(ByVal pMxDFileName As String, ByVal exportFileName As String, ByVal scale As String)

        Dim pMxDoc As IMapDocument
        Dim pActiveView As IActiveView
        Dim docExport As IExport
        Dim pWorldFileSettings As IWorldFileSettings
        Dim iOutputResolution = 300 '300
        Dim iScreenResolution = 96
        Dim RasterSettings As IOutputRasterSettings

        scale = scale + "000"
        pMxDoc = New ESRI.ArcGIS.Carto.MapDocument


        pActiveView = pMxDoc.ActiveView

        Dim pTiffExporter As IExportTIFF = New ExportTIFF
        pTiffExporter.GeoTiff = True
        pTiffExporter.CompressionType = esriTIFFCompression.esriTIFFCompressionLZW
        docExport = pTiffExporter
        pWorldFileSettings = docExport
        pWorldFileSettings.MapExtent = pActiveView.Extent
        pWorldFileSettings.OutputWorldFile = True
        Dim docPrintAndExport As IPrintAndExport = New PrintAndExport
        Dim bClipToGraphicsExtent As Boolean = True

        If TypeOf docExport Is IOutputRasterSettings Then
            ' for vector formats, assign a ResampleRatio to control drawing of raster layers at export time
            RasterSettings = docExport
            RasterSettings.ResampleRatio = 1 'lResampleRatio

            'NOTE:  for raster formats output quality of the DISPLAY is set to 1 for image export formats by default which is what should be used
        End If

        docExport.ExportFileName = exportFileName

            Dim pPage As IPageLayout = pMxDoc.PageLayout
            pActiveView = pPage
            docPrintAndExport.Export(pActiveView, docExport, iOutputResolution, bClipToGraphicsExtent, Nothing)
            Console.WriteLine("Export Complete")
        Catch ex As Exception
            Console.WriteLine("Export Fail")
            '    MessageBox.Show(ex.Message)
        End Try


    End Sub