Universal Document Converter
Product Overview
Download
Purchase
Tutorials
Developer Solutions
Support Service
About fCoder Group


      Site search
   


      Video tutorial
Show tutorial


Main page>Developer Solutions>Popular Applications as COM-servers

Print Autodesk AutoCAD Drawing to Image Using Visual Basic.NET


Universal Document Converter is virtual printer software that saves any document you print as an image file. Below is a source code example that can help you to accomplish your task with Universal Document Converter. Please let us know if you cannot find the solution you need.

' Autodesk AutoCAD 2000 or above and Universal Document Converter
' should be installed on your PC

Private Sub PrintAutoCADDrawing(ByVal strFilePath As String)

' Define constants
  Const acExtents = 1
  Const acScaleToFit = 0

' Run AutoCAD as COM-server
  On Error Resume Next
  Dim App As Object
  Dim Drawing As Object
  Dim Layout As Object
  Dim ActiveSpace As Object

  App = CreateObject("AutoCAD.Application")

' Open drawing from file
  Drawing = App.Documents.Open(strFilePath, False)

  If Drawing = Not Nothing Then

  ' Change AutoCAD preferences for scaling the drawing to page
    If Drawing.ActiveSpace = 0 Then

      ActiveSpace = Drawing.PaperSpace
      Layout = ActiveSpace.Layout

    Else

      ActiveSpace = Drawing.ModelSpace
      Layout = ActiveSpace.Layout

    End If

    Layout.PlotType = acExtents
    Layout.UseStandardScale = True
    Layout.StandardScale = acScaleToFit

    ' Plot the drawing
    Call Drawing.Plot.PlotToDevice("Universal Document Converter")

    ' Close drawing
    Call Drawing.Close(False)
    Drawing = Nothing

  End If

' Close Autodesk AutoCAD
  Call App.Quit()
  App = Nothing

End Sub



Related topics
Popular pages
Popular solutions


© 2001-2008 fCoder Group, Inc. About fCoder Group | Privacy Policy | Site Map