File Dialog Operation for saving PDF Print

File Dialog Operation for saving PDF Print

philip1009
Advisor Advisor
1,070 Views
2 Replies
Message 1 of 3

File Dialog Operation for saving PDF Print

philip1009
Advisor
Advisor

I previously had a rule that would export PDF copies of prints without issue:

 

SyntaxEditor Code Snippet

modelname=IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
ofilename=ThisDoc.FileName(False)
opath="O:\CAD\Released Sales Cads\2017\"+iProperties.Value(modelname,"Custom","PRODUCT_LINE")
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
oOptions.Value("All_Color_AS_Black")=0
oOptions.Value("Remove_Line_Weights")=0
oOptions.Value("Vector_Resolution")=4800
oOptions.Value("Sheet_Range")=Inventor.PrintRangeEnum.kPrintAllSheets
odatamedium.FileName=opath & "\" & ofilename & ".pdf"
oPDFAddin.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

But the exported PDFs would have a layer visibility section when opened in Adobe Reader, since it's not optional to turn this option off during export, I have to resort to using the "Microsoft Print to PDF" during printing.  Here's the code as I have it now:

 

SyntaxEditor Code Snippet

oPrintMgr=ThisApplication.ActiveDocument.PrintManager
oPrintMgr.Printer="Microsoft Print to PDF"
oPrintMgr.ColorMode=kPrintDefaultColorMode
oPrintMgr.Orientation=kLandscapeOrientation
oPrintMgr.Scale=kPrintBestFitScale
oPrintMgr.PaperSize=kPaperSizeC
oPrintMgr.SubmitPrint
'[ This area needs completion!
pdfname=ThisDoc.FileName(False)
modelname=IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)
filepath="O:\CAD\Released Sales Cads\2017\"+iProperties.Value(modelname,"Custom","PRODUCT_LINE")
'Create file dialog operation to automatically select correct folder via "filepath" and correct file name via "pdfname"
']

 

The print options code is working fine, but after that's finished I'm presented with a file dialog box for me to navigate to the folder I want and type in the correct file name.

 

What is the code to automatically save this pdf print using "pdfname" as the filename and "filepath" as the directory to save the file?

 

Thanks for your time.

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

philip1009
Advisor
Advisor
Accepted solution

Never mind, I just answered my own question, replace oPrintMgr.SubmitPrint with oPrintMgr.PrintToFile(filepath+"\"+pdfname+".pdf") and it works perfectly.

Message 3 of 3

bradeneuropeArthur
Mentor
Mentor
Hi,

You could use the inventor add in for exporting the file to pdf too.
With this ZOO of the add in you are able to do more in comparison with printing to a printer.
If needed or interested I can show privide you the code .

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes