Export a pageLayout to PDF in ArcObjects

Discussion created by jmj98 on Jan 18, 2011
Latest reply on Jan 24, 2011 by vtammineni

We are migrating an application in 9.2 to version 10.
The following VB code. NET converted to PDF in version 9.2 but returns a blank page used in Arcgis 10.

Anyone know how to export to PDF the active layout (SDK. NET ArcGis 10)?

Thanks in advance (JMJ98)

        Dim lScrRes As Long
        Dim pExporter As IExporter
        Dim deviceRECT As tagRECT
        Dim pDriverBounds As IEnvelope
        Dim pCancel As ITrackCancel
        Dim nomExportacio As String
        Dim pExport As IExport
        Dim iScreenResolution As Integer
        Dim iOutputResolution As Integer
        Dim exportRECT As tagRECT
        Dim pPixelBoundsEnv As IEnvelope
        Dim hdc As Long
        Dim deviceFrameRect As tagRECT
        Dim pActiveView As IActiveView
        Dim tmpDC As Long
        Dim faExportacio As Boolean
        Dim formatoImagen As String
        Dim pMxDoc As IMxDocument
        Dim objFactory As IObjectFactory
        Dim nom As String
        Dim pageL As IPageLayout
        Dim map As IMap
        Dim psi As New ProcessStartInfo()

            faExportacio = False
            pActiveView = pMxDoc.PageLayout
            pageL = New PageLayout
            pageL = pActiveView
    If formatoImagen = "PDF" Then
                pExporter = objFactory.Create("esriOutput.PDFExporter")
                nomExportacio = nom
                pExporter.ExportFileName = nomExportacio
                With deviceFrameRect
                    .left = 0
                    .right = 800
                    .top = 0
                    .bottom = 600
                End With
                'pActiveView.ScreenDisplay.DisplayTransformation.DeviceFrame = deviceFrameRect
                tmpDC = GetDC(0)
                iScreenResolution = GetDeviceCaps(tmpDC, 88)  '88 is Win32 constant for LOGPIXELSX
                ReleaseDC(0, tmpDC)
                iOutputResolution = 1200
                pExporter.Resolution = iOutputResolution
                With exportRECT
                    .left = pActiveView.ExportFrame.left * (iOutputResolution / iScreenResolution)
                    .top = * (iOutputResolution / iScreenResolution)
                    .right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution)
                    .bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution)
                End With
                pPixelBoundsEnv = New Envelope
                pPixelBoundsEnv.PutCoords(exportRECT.left,, exportRECT.right, exportRECT.bottom)
                pExporter.PixelBounds = pPixelBoundsEnv
                hdc = pExporter.StartExporting
                pCancel = New CancelTracker
                pActiveView.Output(hdc, iOutputResolution, exportRECT, pageL.Page.PrintableBounds, pCancel)
                faExportacio = True
                psi.FileName = System.Windows.Forms.Application.StartupPath.ToString & "\tmp\" & cmbParametro.Text & ".pdf"
    End If