I am writing an automation that opens an AutoCAD drawing in DraftSight, and saves as PDF. The problem is, the page size, orientation, scaling, etc. are pre-selected, and the drawing goes off the edge of the page. It is not obvious as to what properties to manipulate to change this, or how to manipulate them - many of them return the variant type Object instead of a class type, and I cannot find any examples of how to do this.
Here is what I have so far. I thought maybe accessing the PrintManager.AvailablePaperSizes() might lead me there, but it is not clear what type of object that returns.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim dsApp As New DraftSight.Interop.dsAutomation.Application
If dsApp Is Nothing Then
MsgBox("Error - Unable to launch DraftSight.")
Else
Debug.Print("Success. Attempting to open drawing...")
Dim file1 As String = "C:\\Users\\jimerman\\Desktop\\L51AR00200C00.dwg"
Dim tmpfolder As String = Path.GetDirectoryName(file1)
Dim dsDoc As DraftSight.Interop.dsAutomation.Document = dsApp.OpenDocument(file1, _ dsDocumentOpenOption_e.dsDocumentOpen_Default)
If dsDoc Is Nothing Then
MsgBox("Error - Unable to open document '" & file1)
Else
dsApp.Visible = False
Debug.Print("Success. Attempting to save PDF...")
Dim baseName As String = Path.GetFileNameWithoutExtension(file1)
Dim saveName As String = String.Format("{0}\\{1}.pdf", tmpfolder, baseName)
Debug.Print("-- Output name: " & saveName)
Dim prtMgr As DraftSight.Interop.dsAutomation.PrintManager = dsApp.GetPrintManager()
prtMgr.Printer = "PDF"
prtMgr.PrintOut(1, saveName)
dsApp.CloseDocument(file1, False)
End If
Try
dsApp.ExitApplication()
Catch ex As Exception
End Try
MsgBox("Done")
End If
End Sub
