ShowSaveCopyAsOption does not work with options

ShowSaveCopyAsOption does not work with options

tobias_wiesendanger
Advocate Advocate
238 Views
2 Replies
Message 1 of 3

ShowSaveCopyAsOption does not work with options

tobias_wiesendanger
Advocate
Advocate

As the title describes, could it be possible that ShowSaveCopyAsOption does not load the options that are provided with parameters?

 

If I do something like this:

Call PDFAddIn.ShowSaveCopyAsOptions( SourceObject, Context, Options)

then it looks like it doesnt matter what Options I provide. I was expection to see these reflected in the dialog, at least that is how I remember it working.

 

I especially set Options.Value("All_Color_AS_Black") = 1 so I was expecting to see this option checked inside the dialog.

 

Full code:

 

Sub GetPDFOptions()
  Dim app As Application
  Set app = ThisApplication

  Dim addins As ApplicationAddIns
  Set addins = app.ApplicationAddIns

  ' Get the DWF AddIn using its ID
  Dim PDFAddIn As TranslatorAddIn
  Set PDFAddIn = addins.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

  ' Activate AddIn
  PDFAddIn.Activate

  Dim SourceObject As Object
  Dim Context As TranslationContext
  Dim Options As NameValueMap

  Dim transientObj As TransientObjects
  Set transientObj = app.TransientObjects

  Set Context = transientObj.CreateTranslationContext
  Context.Type = kUnspecifiedIOMechanism
  Set Options = transientObj.CreateNameValueMap
  Set SourceObject = ThisApplication.ActiveDocument
    Options.Value("All_Color_AS_Black") = 1
  ' Check if the translator has 'SaveCopyAs' options
  If PDFAddIn.HasSaveCopyAsOptions( _
    SourceObject, Context, Options) Then
    
    ' You can also show the Options dialog
    ' and then set whatever you need, then
    ' check here how those settings are stored
    Call PDFAddIn.ShowSaveCopyAsOptions( _
      SourceObject, Context, Options)
    
    ' Now print out the values
    Call PrintInfo(Options, 1)
  End If
End Sub

Sub PrintInfo(v As Variant, indent As Integer)
  If TypeOf v Is NameValueMap Then
    Dim nvm As NameValueMap
    Set nvm = v
    Dim i As Integer
    For i = 1 To nvm.Count
      Debug.Print Tab(indent); nvm.Name(i)
      Call PrintInfo(nvm.Value(nvm.Name(i)), indent + 1)
    Next
  Else
    Debug.Print Tab(indent); v
  End If
End Sub

 

0 Likes
239 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @tobias_wiesendanger.  I believe those last two 'input' variables are just supposed to be empty when supplied to that method, then that method fills them in, based on the options you choose while the dialog is open.  Then you can check the options you chose by code after the dialog is closed.  There would not really be any need for it to work the other way around.  It's the same for the HasSaveCopyAsOptions method.  We just call that ahead of time, so that those variables will be assigned the default values (or the values that were used the last time).  Then we specify which options we want a certain way after that point.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

tobias_wiesendanger
Advocate
Advocate

It looks like that. The plan was to use this dialog so the user can set his prefered option we then use to export. So in this case this would have been great. So the next time he open the dialog it should show hat he selected. Anyway, we can build our own dialog. Thanks

0 Likes