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()
var d = app.activeDocs;
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.
' 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
'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
Set oJSObject = oAcroPDDoc.GetJSObject
'Execute some more code
'So far, so good
'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
'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
'Acrobat 8 returns an array that includes the doc object; Acrobat 9 returns an empty array
'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.)
Message was edited by: Bill Erickson, 6:43PM 5/4/09