zoukankan      html  css  js  c++  java
  • 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
             
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    linux 多进程并发服务__关于子进程回收的方法
    Qt中图元对象的多重集成
    Qmake: Q_OBJECT
    Qt Creator 启动失败 可能的解决办法
    Oracle 系统改变号SCN详解
    rman之创建恢复目录笔记
    Oracle 生成和显示执行计划的方法
    系统数据文件备份与恢复及只读数据文件备份与恢复
    没有备份、只有归档日志,如何恢复数据文件?
    ORACLE UNDO REDO查看
  • 原文地址:https://www.cnblogs.com/fanxingthink/p/4176151.html
Copyright © 2011-2022 走看看