• C# CAD环境下DWG转PDF 使用命令


    CAD环境下DWG转PDF

      Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    
            Dim f As FileInfo = New FileInfo("E:j9-FwfeplGMIpixSqiD9d.dxf")
            Dim f1 As FileInfo = New FileInfo("E:[3500×0×2][数量10](1).dxf")
            'Dim f2 As FileInfo = New FileInfo("E:j9-FwfeplGMIpixSqiD9d.dxf")
            'Dim f3 As FileInfo = New FileInfo("E:j9-FwfeplGMIpixSqiD9d.dxf")
    
            Dim list = New List(Of FileInfo)()
            list.Add(f)
            list.Add(f1)
            Dwg2Pdf(list)
    
    
        End Sub
    Public Shared Sub Dwg2Pdf(ByVal files As List(Of FileInfo))
    
            Dim doc As AcadDocument = Nothing
            Dim destPath As String = String.Empty
            'InitializationApp()
    
            Dim activeDoc As Document = Application.DocumentManager.MdiActiveDocument
            'Dim ThisDrawing As AcadDocument = CType(activeDoc.AcadDocument, AcadDocument)
    
    
    
            Try
    
                For Each f In files
                    'doc = _app.Documents.Open(f.FullName, True)
                    doc = Application.DocumentManager.Open(f.FullName, True).AcadDocument
                    'doc = ThisDrawing.Open(f.FullName, True)
                    'ThisDrawing.LoadShapeFile(f.FullName)
    
                    'doc = ThisDrawing
    
                    doc.SetVariable("sdi", 0)
                    doc.SetVariable("Filedia", 0)
                    doc.SetVariable("RASTERPREVIEW", 1)
                    doc.SetVariable("BACKGROUNDPLOT", 0)
                    doc.ActiveLayout.ConfigName = "DWG To PDF.pc3"
                    doc.ActiveLayout.UseStandardScale = True
                    doc.ActiveLayout.StandardScale = AcPlotScale.acScaleToFit
                    doc.ActiveLayout.PlotType = AcPlotType.acExtents
                    doc.ActiveLayout.CenterPlot = True
                    doc.ActiveLayout.PlotRotation = AcPlotRotation.ac0degrees
                    doc.ActiveLayout.PlotType = Autodesk.AutoCAD.Interop.Common.AcPlotType.acExtents
                    doc.Plot.QuietErrorMode = True
                    destPath = Path.Combine(f.Directory.FullName, Path.GetFileNameWithoutExtension(f.Name) & ".pdf")
                    doc.Plot.PlotToFile(destPath)
                    If doc IsNot Nothing Then doc.Close(False)
                Next
    
            Catch e As System.Exception
                Throw e
            Finally
    
                Try
                    doc.Close(False)
                    _app.Quit()
                Catch
                End Try
            End Try
        End Sub
    

      

    源码地址 :https://download.csdn.net/download/bosslizhiyong/12414134

  • 相关阅读:
    经典哦,男女3.8,8.3
    在web窗体设计器中未能加载该文件
    使用客户端脚本
    C#的数据类型
    实验下cookie
    C#中Split分隔字符串的应用
    未将对象引用设置到对象的实例
    System.StackOverflowException 的异常;jit调试失败
    DataGrid中添加删除确认对话框 多种实现
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/shangdishijiao/p/12882929.html
Copyright © 2020-2023  润新知