Inventor API VB.Net PDF Translator creates unusable files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using Inventor 2017 and I created a VB.Net addin that iterates through an assembly, finds drawings, and uses the PDF Translator to create to PDF Files.
However, the pdf files are unusable.
Attached are files that were created from the translator and one from INventor directly.
Here is the code that creates the pdf files.
Public Sub PublishPDF(ByRef DrawingFName As String)
Dim DrawingDocument As Document = invApp.Documents.Open(DrawingFName, False)
Dim PDFAddIn As Inventor.TranslatorAddIn
PDFAddIn = invApp.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
Dim oContext As Inventor.TranslationContext
oContext = invApp.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oOptions As Inventor.NameValueMap
oOptions = invApp.TransientObjects.CreateNameValueMap
Dim oDataMedium As Inventor.DataMedium
oDataMedium = invApp.TransientObjects.CreateDataMedium
If PDFAddIn.HasSaveCopyAsOptions(DrawingDocument, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = My.Settings.PDFAllColorsAsBlack
oOptions.Value("Remove_Line_Weights") = My.Settings.PDFLineweight
oOptions.Value("Vector_Resolution") = My.Settings.PDFVectorResolution
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If
Dim oDrawName As String ' Use to store drawing filename. Remove path, extension and replace with PDFFoldername and pdf extension
oDrawName = PDFFolderName + "\" + System.IO.Path.GetFileNameWithoutExtension(DrawingFName) + ".pdf"
oDataMedium.FileName = oDrawName
Call PDFAddIn.SaveCopyAs(DrawingDocument, oContext, oOptions, oDataMedium)
DrawingDocument.Close()
End Sub