Export PDF from .NET VS 2008 application

693
0
03-08-2011 01:26 AM
JMJJDJM
New Contributor
Hi
I try to print to PDF.
As a test using the sample code of "DesktopAutomationVB2008.sln" and the Sub ExportActiveViewParameterized

Someone can give me ideas of why PDF is a blank pdf.

Thanks.
JMJ98

Code of ExportActiveViewParameterized
'----------------------------------------------------------------------------------------------
Public Sub ExportActiveViewParameterized(ByVal nom As String, ByVal ExportFormat As String, ByVal iOutputResolution As Long, ByVal lResampleRatio As Long, ByVal bClipToGraphicsExtent As Boolean)

        'Export the active view using the specified parameters
        Dim docActiveView As IActiveView
        Dim docExport As IExport
        Dim docPrintAndExport As IPrintAndExport
        Dim RasterSettings As IOutputRasterSettings
        Dim sNameRoot As String
        Dim sOutputDir As String
        Dim bReenable As Boolean
        Dim pCancel As ITrackCancel


        If (GetFontSmoothing()) Then
            bReenable = True
            DisableFontSmoothing()
            If (GetFontSmoothing()) Then
                MsgBox("Cannot Disable Font Smoothing.  Exiting.")
                Return
            End If
        End If
        Dim pMxDoc As IMxDocument
        pMxDoc = m_application.Document
        docActiveView = pMxDoc.PageLayout

        Select Case ExportFormat
            Case "PDF"
                docExport = New ExportPDF
            Case "EMF"
                docExport = New ExportEMF
            Case "BMP"
                docExport = New ExportBMP
            Case "EPS"
                docExport = New ExportPS
            Case "SVG"
                docExport = New ExportSVG
            Case "GIF"
                docExport = New ExportGIF
            Case "TIF"
                docExport = New ExportTIFF
            Case "JPEG"
                docExport = New ExportJPEG
            Case "PNG"
                docExport = New ExportPNG
            Case "AI"
                docExport = New ExportAI
            Case Else
                MessageBox.Show("Formato de Salida desconocido, por defecto se usa EMF")
                ExportFormat = "EMF"
                docExport = New ExportEMF
        End Select

        docPrintAndExport = New PrintAndExport

        ' Output Image Quality of the export.  The value here will only be used if the export
        '  object is a format that allows setting of Output Image Quality, i.e. a vector exporter.
        '  The value assigned to ResampleRatio should be in the range 1 to 5.
        '  1 corresponds to "Best", 5 corresponds to "Fast"

        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 = 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

        'assign the output path and filename.  We can use the Filter property of the export object to
        ' automatically assign the proper extension to the file.

        docExport.ExportFileName = nom
        pCancel = New CancelTracker
        docPrintAndExport.Export(pMxDoc.ActiveView, docExport, iOutputResolution, bClipToGraphicsExtent, pCancel)

        'cleanup for the exporter
        docExport.Cleanup()

        If (bReenable) Then
            EnableFontSmoothing()
            bReenable = False
        End If
    End Sub
'-----------------------------------------------------------------------------------
0 Kudos
0 Replies