Proe 导出PDF Vb.net

Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        Dim instructions As IpfcPDFExportInstructions
        Dim CoCreoSession As IpfcBaseSession
        Dim outPath As String
        
        Try
            Dim run As New pfcModelsExamples
            asyncConnection = Casync.Connect(DBNull.Value, DBNull.Value, DBNull.Value, DBNull.Value)
            CoCreoSession = asyncConnection.Session

            Dim descModel As IpfcModelDescriptor
            descModel = (New CCpfcModelDescriptor).Create(EpfcModelType.EpfcMDL_DRAWING, Nothing, Nothing)
            descModel.Path = "C:\Documents and Settings\Administrator\My Documents\drw0001.drw.1"

            'Dim LmodDoc As IpfcModel = CoCreoSession.GetModelFromDescr(descModel)
            Dim LmodDoc As IpfcModel = retrieveModelFromStdDir(CoCreoSession, EpfcModelType.EpfcMDL_DRAWING, "C:\Documents and Settings\Administrator\My Documents\drw0001.drw.1")


            If Not LmodDoc Is Nothing Then
                LmodDoc.Display()
                CoCreoSession.CurrentWindow.Activate()
            End If

            instructions = (New CCpfcPDFExportInstructions).Create()

            outPath = "c:\work\" + LmodDoc.InstanceName.ToLower + ".pdf"
            LmodDoc.Export(outPath, instructions)
            If Not LmodDoc Is Nothing Then CoCreoSession.CurrentWindow.Close()
        Catch ex As Exception
            MsgBox(ex.Message & vbNewLine & ex.StackTrace)
        End Try
    End Sub

    Public Function retrieveModelFromStdDir(ByVal session As IpfcBaseSession, _
                                            ByVal type As EpfcModelType, _
                                            ByVal stdPath As String) As IpfcModel

        Dim descModel As IpfcModelDescriptor
        Dim options As IpfcRetrieveModelOptions
        Dim model As IpfcModel

        Try
            '======================================================================
            'Model is retrieved using a model descriptor object.
            'This method loads the model identified by model type and path from a 
            'standard directory location.
            '======================================================================
            options = (New CCpfcRetrieveModelOptions).Create
            options.AskUserAboutReps = False

            descModel = (New CCpfcModelDescriptor).Create(type, Nothing, Nothing)
            descModel.Path = stdPath

            model = session.RetrieveModelWithOpts(descModel, options)

            retrieveModelFromStdDir = model

        Catch ex As Exception
            MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
            Return Nothing
        End Try

    End Function


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值