Inventor API VB.Net PDF Translator creates unusable files

Inventor API VB.Net PDF Translator creates unusable files

J_Dumont
Advocate Advocate
831 Views
2 Replies
Message 1 of 3

Inventor API VB.Net PDF Translator creates unusable files

J_Dumont
Advocate
Advocate

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

 

 

0 Likes
Accepted solutions (1)
832 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

It looks like it is setting your "Vector_Resolution" extremely low for some reason.

How are you defining the values of your oOptions?  I'm seeing values that start with My.Settings.PDF....

I just set those values with either a 0 or 1 (zero equals false and one equals true) or for resolution I input a simple number like 720, or 4800.

Also, I know it's not related but, how are you defining "PDFFolderName"?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

J_Dumont
Advocate
Advocate

The default resolution Inventor uses is 400 DPI. I started here and then went to the highest value with similar results.

The oPtions is getting info from the program Settings which is retrieved with My.Settings.

J_Dumont_0-1596567598802.png

Based on your question I changed the data type from String to Integer and that seemed to do the trick.

J_Dumont_1-1596567733553.png

 

Thanks for your input.

 

 

0 Likes