
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
This is probably a beginner error, but I can't get past this issue. I found this bit of code in one of the Autodesk blogs and tried to make it work in my application. I want to create a PDF from a given file on the local disk.
.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim fileFullName As String = "C:\PublishFolder\2000034_2.ipt" ' Create a new instance of Inventor Dim _invApp As Inventor.Application Dim invAppType As Type = GetTypeFromProgID("Inventor.Application") _invApp = CreateInstance(invAppType) _invApp.Visible = False _invApp.SilentOperation = True ' Open a document Dim oDoc As Inventor.Document oDoc = _invApp.Documents.Open(fileFullName, True) ' Get the PDF translator Add-In Dim PDFAddIn As TranslatorAddIn PDFAddIn = _invApp.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") 'Set a reference to the active document (the document to be published) Dim oDocument As Document oDocument = _invApp.ActiveDocument Dim oContext As TranslationContext oContext = _invApp.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism ' Create a NameValueMap object Dim oOptions As NameValueMap oOptions = _invApp.TransientObjects.CreateNameValueMap ' Create a DataMedium object Dim oDataMedium As DataMedium oDataMedium = _invApp.TransientObjects.CreateDataMedium ' Check whether the translator has 'SaveCopyAs' options If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then ' Options for drawings... oOptions.Value("All_Color_AS_Black") = 0 'oOptions.Value("Remove_Line_Weights") = 0 'oOptions.Value("Vector_Resolution") = 400 'oOptions.Value("Sheet_Range") = kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'Set the destination file name oDataMedium.FileName = fileFullName & ".pdf" 'Publish document. Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub
When the code tries to execute "Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)" it throws an "COMException was unhandled" error.
As I understand the apprenticeserver dont have the functionallity to create PDF's thats why I try to do it with a hidden Inventor instance (I also want to create other formats, but PDF is the first priority)
Any help or pointers to documentation that can explain this error to me would be greatly appreciated. Thanks
Regards
Bredo
Solved! Go to Solution.