Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Exporting PDF, HasSaveCopyAsOptions returns false

1 REPLY 1
SOLVED
Reply
Message 1 of 2
etckerry
855 Views, 1 Reply

Exporting PDF, HasSaveCopyAsOptions returns false

Hello,

 

I have a VB.NET routine that exports a pdf using the TranslatorAddIn interface.  I copied the example from the api help.

 

The pdf is created, but only the first sheet of the drawing is exported.  I uncommented the following line in the example code, and still no change:

oOptions.Value("Sheet_Range") = kPrintAllSheets

 

I added a message box, to make sure I was reaching that line, and I found that I was not in fact reaching that line.  Why is this?  In some posts here related to dwf exporting also using the TranslatorAddIn, the first argument of HasSaveCopyAsOptions was oDataMedium instead of oDocument, so I tried that, too, but still no change.

 

Here is the code of the export to PDF routine from the api example:

 

Public Sub PublishPDF()
    ' Get the PDF translator Add-In.
    Dim PDFAddIn As TranslatorAddIn
    Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

    'Set a reference to the active document (the document to be published).
    Dim oDocument As Document
    Set oDocument = ThisApplication.ActiveDocument

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

    ' Create a NameValueMap object
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Create a DataMedium object
    Dim oDataMedium As DataMedium
    Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

    ' Check whether the translator has 'SaveCopyAs' options
    If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

        ' Options for drawings...

        oOptions.Value("All_Color_AS_Black") = 0

        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        'oOptions.Value("Sheet_Range") = kPrintAllSheets
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4

    End If

    'Set the destination file name
    oDataMedium.FileName = "c:\temp\test.pdf"

    'Publish document.
    PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

 

 Thanks,

 

Kerry

 

1 REPLY 1
Message 2 of 2
00ash00
in reply to: etckerry

Hi Kerry,

 

One of the lines in the code is wrong,

oContext.Type = kFileBrowseIOMechanism

if you change it to this below it should work fine for you.

 

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

 

Ash

Ash

Dell - T1650
Intel(R)Xeon(R) CPU E3-1290 V2 @ 3.70GHz
16GB
64-Bit
Windows 7 Pro
Inventor 2013 Build: 138

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report