PDF rule does not work anymore with newer INVENTOR

PDF rule does not work anymore with newer INVENTOR

vkulikajevas
Advocate Advocate
414 Views
2 Replies
Message 1 of 3

PDF rule does not work anymore with newer INVENTOR

vkulikajevas
Advocate
Advocate

PDF export rule used to work, now shows "Invalid Point" Error and no PDF is created

 

oPath = ThisDoc.Path
'msgbox(oPath)
oFileName = ThisDoc.FileName(False)
oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If

'oFolder = oPath & "\PDF" 

'If Not System.IO.Directory.Exists(oFolder) Then
'    System.IO.Directory.CreateDirectory(oFolder)
'End If

oDataMedium.FileName = oPath & "\" & ThisDoc.FileName(False) & ".pdf"
'MsgBox(FileName)
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

 

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

rhasell
Advisor
Advisor

Hi

A few versions ago, something changed, but I can't remember what it was, the PDF export stopped working, this was quickly fixed by the forum members.

I have updated your code with a merged extract from mine, I changed the resolution from 4800 to 400, again something changed with version 2022, and the resolution started working correctly. Therefore, 4800 resolution starts creating huge files, which for the most part is not necessary. You can change it back again if desired.

 

 

Dim oDoc As Document
oDoc = ThisDoc.Document
Dim oPDFAddIn As TranslatorAddIn
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

Dim oDocument As Document
oDocument = ThisDoc.Document

Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oDataMediumPDF As DataMedium
oDataMediumPDF = ThisApplication.TransientObjects.CreateDataMedium

'--PDF settings---
'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
	oOptions.Value("All_Color_AS_Black") = 0
	oOptions.Value("Remove_Line_Weights") = 0
	oOptions.Value("Vector_Resolution") = 400
	oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
End If
'---End PDF settings

'---
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oDocument = ThisDoc.Document
oDataMediumPDF.FileName = oPath + "\" + oFileName & ".pdf"

'Check for Existing File
If System.IO.File.Exists(oDataMediumPDF.FileName) Then
	oChoice = MessageBox.Show(oDataMediumPDF.FileName & " Already Exists - Overwrite?", "Title", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
	If oChoice = 7
		'MessageBox.Show("exit", "Title")
		Return
	Else
		'MessageBox.Show("Overwrite", "Title")
	End If
End If

'''--- Publish document.
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumPDF)

 

Reg
2026.1
0 Likes
Message 3 of 3

rhasell
Advisor
Advisor
Accepted solution

Hi

 

Found the change. it was in the PDF settings IF statement

The oDataMedium statement needed to change.

added the oDoc definition

 

 

 

Dim oDoc As Document
oDoc = ThisDoc.Document
'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then

 

 

 

Here is your original code with the fix.

oPath = ThisDoc.Path
'msgbox(oPath)
oFileName = ThisDoc.FileName(False)
oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oDoc As Document
oDoc = ThisDoc.Document
'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 1
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If

'oFolder = oPath & "\PDF" 

'If Not System.IO.Directory.Exists(oFolder) Then
'    System.IO.Directory.CreateDirectory(oFolder)
'End If

oDataMedium.FileName = oPath & "\" & ThisDoc.FileName(False) & ".pdf"
'MsgBox(FileName)
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

 

Reg
2026.1