Export pdf from VB.net
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm trying to make an application that would take a drawing(dwg) and convert it to pdf. Since I can do it directly in autocad 2013, i presume that there should be a function in the API, that i could use to do the same. So far, i tried with AcadDocument.export(filename, FileExtension, AcadSelectionSet) with no luck. I cannot put PDF as a valid file extension.
Here's my code
Public sub SaveToPDF(ByVal psfilename As String)
Dim oAutocad As AutoCAD.AcadApplication = New AutoCAD.AcadApplication()
Dim oAcadDoc As AutoCAD.AcadDocument = oAutocad.Documents.Open(psfilename, True)
Dim sFolder As String = psfilename.Substring(0, psfilename.LastIndexOf("\") + 1)
Dim sFilename As String = psfilename.Substring(psfilename.LastIndexOf("\") + 1, (psfilename.Length - psfilename.LastIndexOf("\")) - (psfilename.Length - psfilename.LastIndexOf(".") + 1))
Dim oSS As AcadSelectionSet = Nothing
Try oSS = oAutocad.ActiveDocument.SelectionSets.Add("MySet")
oSS.Select(AcSelect.acSelectionSetAll)
oAutocad.ActiveDocument.Export(sFolder & sFilename & ".pdf", ".pdf", oSS)
oSS.Delete() Catch ex As Exception success = False oSS.Delete()
oSS = Nothing
End Try
For Each Doc In oAutocad.Documents
Doc.Close(False)
Next
oAutocad.Quit()
oAutocad = Nothing
end sub
Does anyone have an idea?
Thanks