Print on save to non default printer (Code Help)

Print on save to non default printer (Code Help)

Anonymous
Not applicable
529 Views
1 Reply
Message 1 of 2

Print on save to non default printer (Code Help)

Anonymous
Not applicable

The code below works great for making PDF’s when you save the drawing. I just have one little problem…. All of our drawing templates are D size for work related reasons (They cannot be changed to B size). Our customers want B size PDF’s and this code will only make the PDF’s the same size as the drawing sheet size. Is there a way to change the exported sheet size when making a PDF in Inventor?

 

Currently we are using the print manager (CutePDF Writer) and changing the size of the sheets in the properties.

 

I guess what I’m asking is there a way to get a non default printer (in the print manager) to print on save? Thank you for any help you might be able to give.

 

 

 

oPath = ThisDoc.Path

oFileName = ThisDoc.FileName(False) 'without extension

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") = 1

oOptions.Value("Vector_Resolution") = 400

oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets

'oOptions.Value("Custom_Begin_Sheet") = 2

'oOptions.Value("Custom_End_Sheet") = 4

End If

 

'get PDF target folder path

oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF"

 

'Check for the PDF folder and create it if it does not exist

If Not System.IO.Directory.Exists(oFolder) Then

    System.IO.Directory.CreateDirectory(oFolder)

End If

 

 'Set the PDF target file name

oDataMedium.FileName = oFolder & "\" & oFileName & _

" Rev" & oRevNum & ".pdf"

 

'Publish document

oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

0 Likes
530 Views
1 Reply
Reply (1)
Message 2 of 2

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

If you check all the available parameters of the PDF Translator after the HasSaveCopyAsOptions() call, then you'll see that it does seem to contain size related option. 😞

    Dim i As Integer
    For i = 1 To nvm.Count
        Dim obj As Variant
        obj = nvm.Item(i)
        
        If TypeName(obj) <> "String" Then
            obj = str(obj)
        End If
        
        Debug.Print nvm.name(i) + " = " + obj
    Next
End Sub

Values

Publish_All_Sheets =  0
Publish_3D_Models =  0
Launch_Viewer =  1
Password = 
Publish_Mode =  62721
Enable_Large_Assembly_Mode =  0
Enable_Measure =  1
Enable_Printing =  1
Enable_Markups =  1
Enable_Markup_Edits =  1
Output_Path = 
Include_Sheet_Tables =  1
Sheet_Metal_Flat_Pattern =  0
Sheet_Metal_Style_Information =  0
Sheet_Metal_Part =  1
Weldment_Preparation =  0
Weldment_Symbol =  0
BOM_Structured =  1
BOM_Parts_Only =  1
Animations =  0
Instructions =  0
iAssembly_All_Members =  0
iAssembly_3D_Models =  0
iPart_All_Members =  0
iPart_3D_Models =  0
Publish_Component_Props =  1
Publish_Mass_Props =  1
Include_Empty_Properties =  0
Publish_Screenshot =  0
Screenshot_DPI =  96
Facet_Quality =  69379
Override_Sheet_Color =  0
Sheet_Color =  0
Sheet_Range =  14081
Custom_Begin_Sheet =  1
Custom_End_Sheet = -1
All_Color_AS_Black =  0
Remove_Line_Weights =  0
Vector_Resolution =  400
TranscriptAPICall =  0

If I understand correctly you are using Cute PDF and that works?

Another option I'm thinking about (did not test it) is what would happen if you changed the sheet sizes inside a transaction, printed them with the PDF Translator, then abort the transaction? Would that be an option?

I hope this helps.

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes