0 Replies Latest reply on May 4, 2009 3:45 PM by wildcathoya

    App.activeDocs works in VB.NET with Acrobat 8 but not with Acrobat 9

    wildcathoya Level 1

      I've rewritten enough of my app in VB.Net to test App.activeDocs using the the JS object.  As before, it works with Acrobat 8 but not with Acrobat 9.  Same result: no array of doc objects are returned.

       

      I've wrapped the method in a trusted function in my folder-level .js file, as described in the documentation:

       

      trusted_activeDocs = app.trustedFunction ( function()

      {

           app.beginPriv();

           var d = app.activeDocs;

           app.endPriv();

           return d;

      })

       

      I've also embedded this.disclosed = true; in the document, also described in the documentation.  Neither helps.  It just doesn't work.

       

      Obviously, either there is a bug in the JS object or else additional steps must be taken that are not described in the documentation.

       

      Any suggestions?????????????????????????????????

       

       

      -----------------------------------------------

       

       

      I have a VB6 app that downloads a PDF (actually an FDF) to a WebBrowser control and also downloads the annotations stored in a central database via SOAP.  With Acrobat 8, but not with Acrobat 9, I can get the Javascript doc object with the following VB6 code, which allows me to access the doc object's methods and properties and manipulate the annots.

       

      ---------------------------

       

      ' Module-level variables
      Private oAcroApp As acrobat.AcroApp
      Private oAcroPDDoc As acrobat.AcroPDDoc       
      Private oJSObject As Object                         'Acrobat JS Object
      Private vDocArray As Variant                         'Array of doc objects returned by App.activeDocs
      Private strDownloadedPdfUrl As String                'This is the URL of the downloaded PDF from WebBrowser.NavigateComplete2
      Private MYDOC As Object                              'This is the Javascript doc object of the downloaded PDF

       


      '1. Create the acrobat objects when the form is loaded

       

      Private Sub Form_Load()

       

          'Execute some code

       

          Set oAcroApp = New AcroApp
          Set oAcroPDDoc = New AcroPDDoc
          oAcroPDDoc.Create
          Set oJSObject = oAcroPDDoc.GetJSObject
         
          'Execute some more code
         
          'So far, so good
         
      End Sub

       

      '2. Execute other subs and functions and then get the URL of the downloaded PDF

       

      Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, url As Variant)


          strDownloadedPdfUrl = CStr(url)


          'So far, so good
         
      End Sub

       

      '3. Get the JS doc object of the downloaded PDF


      Private Sub GetPdfDocObject()

           Dim thisDoc As Object


          vDocArray = oJSObject.App.activeDocs

       

          If IsArray(vDocArray) Then   
              For i = LBound(vDocArray) To UBound(vDocArray)
                  Set thisDoc = vDocArray(i)
                  If thisDoc.url = strDownloadedPdfUrl  Then
                      Set MYDOC = thisDoc
                      Exit For
                  End If
              Next
          End If
         
          'Acrobat 8 returns an array that includes the doc object; Acrobat 9 returns an empty array

       

      End Sub

       

      '4. Under Acrobat 8 but not Acrobat 9, I now have the JS doc object (MYDOC) and can access the various doc methods and properties on the downloaded PDF and manipulate (SetProps) the annots.

       

      ---------------------------

       

      The above code works in Acrobat 8 but not in Acrobat 9.  Specifically, in GetPdfDocObject(), vDocArray = oJSObject.App.activeDocs returns an empty array.

       

      I have tried creating a trusted function in my folder-level .js file to escalate the privilege level and get the docs returned by oJSObject.App.activeDocs.  I have also tried adding "this.global.theDoc = this" to the FDF file because all I really need is the doc object of the PDF.  Both of those approaches work with Acrobat 8 but neither works with Acrobat 9. Moreover, I can no longer change the global variables under Acrobat 9, even when they're wrapped in trusted functions.

       

      Since I can still create the various Acrobat objects and call their methods under Acrobat 9, I don't think the problem is with VB6 (vs. VB.Net), but I could be wrong.  (I'd prefer not to rewrite the app in VB.Net unless absolutely necessary.)

       

      In VB6, how I can get the Javascript doc object for the downloaded PDF under Acrobat 9?  Would the equivalent code work in VB.Net?

       

      Thanks,

       

      Bill Erickson

       

      Message was edited by: Bill Erickson, 6:43PM 5/4/09