• 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 SettingsAdministratorMy Documentsdrw0001.drw.1"
    
                'Dim LmodDoc As IpfcModel = CoCreoSession.GetModelFromDescr(descModel)
                Dim LmodDoc As IpfcModel = retrieveModelFromStdDir(CoCreoSession, EpfcModelType.EpfcMDL_DRAWING, "C:Documents and SettingsAdministratorMy Documentsdrw0001.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


     

    作者:Joe.Fan
             
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Rails 5 Test Prescriptions 第6章Adding Data to Tests
    Rails 5 Test Prescriptions 第4章 什么制造了伟大的测试
    Rails 5 Test Prescriptions 第3章Test-Driven Rails
    VisualBasic6.0程序设计教程(第4版)(普通高等教育“十一五”国家级规划教材)
    Word Excel PPT 2016三合一办公应用实战从入门到精通 超值版
    R语言数据挖掘方法及应用
    Word--Excel 2016商务办公实战从新手到高手
    妙哉!Excel数据分析与处理就该这么学
    Visual C++串口通信开发入门与编程实践
    Hello C 语言
  • 原文地址:https://www.cnblogs.com/fanxingthink/p/4176151.html
Copyright © 2020-2023  润新知