I'm using Adobe Acrobat's COM interface to manipulate the contents of a PDF document hosted in a window provided by my application.
Adobe seem to have frozen development of the COM interface around 2006. Although Acrobat's type library provides access to a fairly limited set of functions, the COM interface doesn't provide direct access to many of the functions available in the Acrobat application's menus + toolbars. These days they expect you to be working via their JavaScript API.
The Acrobat type library enables you to get access to a JavaScript object associated with a particular document. For example, the following turns the first page of a document upside-down:
[...]
var
Doc : CAcroPDDoc; // interface Acrobat document
vJS : OleVariant; // access to JavaScript object
begin
Doc := CoAcroPDDoc.Create;
Doc.Open(AFileName);
try
vJS := Doc.GetJSObject;
try
vJS.SetPageRotations(0, 0, 180);
finally
VarClear(vJS);
end;
finally
Doc := Nil;
end;
end;
That works fine where what I want to do just involves invoking a method of one of the objects in the Acrobat JavaScript API. My question is: How do I interface my application's code with the events some of these objects provide? E.g. there is a JS even which occurs when the user clicks a bookmark in the document - how would I go about providing an event handler for something like that?
I know how to implement an outbound interface and to connect it to a COM object via a ConnectionPointContainer/FindConnectionPoint. But I haven't a clue how to connect to a JS event on an object I'm accessing (via a call like GetJSObject above) that's on the other side of a COM object interface. So this isn't a case where I can "show my code so far", because I don't know where to begin.