Here is my code example (in C#):
Type AcrobatAppType = Type.GetTypeFromProgID("AcroExch.App");
Type AcrobatAVDocType = Type.GetTypeFromProgID("AcroExch.AVDoc");
CAcroApp app = (CAcroApp)Activator.CreateInstance(AcrobatAppType);
CAcroAVDoc doc = (CAcroAVDoc)Activator.CreateInstance(AcrobatAVDocType);
if (doc.Open(@"C:\SomeRandom.pdf", ""))
{
CAcroPDDoc pdDoc = doc.GetPDDoc();
Object jso = pdDoc.GetJSObject();
Object search = jso.GetType().InvokeMember("search", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null, jso, null);
Type searchType = search.GetType();
searchType.InvokeMember("query", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, search,new Object[]{ "long word"}); // PROBLEM HERE
}
The problem I am having is with the last line. If I change "new Object[]{ "long word"}" to "new Object[]{ "long word", "ActiveDoc"}", I get a TargetInvocationException.
According to the JavaScript documentation:
(optional) Specifies where the text should be searched. Values are:
ActiveDoc
Folder
Index
ActiveIndexes
My code example shown above works when passing "Folder", "ActiveIndexes" and "Index". The only argument that does not work is "ActiveDoc" and I'm not sure why.
Any clue or solution into what the problem may be would help.