I'm working with C#, and Adobe Acrobat 6.0 Professional. Acrobat exposes a COM Automation server with a few top-level objects. It's easy enough to create instances of those objects, by getting their Type via the .GetTypeFromProgID() method, and then using Activator.CreateInstance().
However, there are other objects that can only be created by calling a method of one of these top-level objects. For example, Acrobat's built-in JavaScript engine can be returned via the "GetJSObject()" method of the PDDoc object.
This code, for example, compiles and runs:
However, since this object isn't strongly typed, it isn't really useful. I can't call any of its inherent methods or properties.
How can you type and instantiate such an object?
Thomas D. Greer
Code:
// Create an Acrobat Application
object Type AcrobatAppType;
AcrobatAppType = Type.GetTypeFromProgID("AcroExch.App");
Acrobat.CAcroApp oAdobeApp = (Acrobat.CAcroApp)Activator.CreateInstance(AcrobatAppType);
// Create an Acrobat Document object
Type AcrobatPDDocType;
AcrobatPDDocType = Type.GetTypeFromProgID("AcroExch.PDDoc");
Acrobat.CAcroPDDoc oAdobePDDoc = (Acrobat.CAcroPDDoc)Activator.CreateInstance(AcrobatPDDocType);
// Create an Acrobat AV Document object
Type AcrobatAvType;
AcrobatAvType = Type.GetTypeFromProgID("AcroExch.AVDoc");
Acrobat.CAcroAVDoc oAdobeAVDoc = (Acrobat.CAcroAVDoc)Activator.CreateInstance(AcrobatAvType);
However, there are other objects that can only be created by calling a method of one of these top-level objects. For example, Acrobat's built-in JavaScript engine can be returned via the "GetJSObject()" method of the PDDoc object.
This code, for example, compiles and runs:
Code:
object oAcrobatJSobj = oAdobePDDoc.GetJSObject();
However, since this object isn't strongly typed, it isn't really useful. I can't call any of its inherent methods or properties.
How can you type and instantiate such an object?
Thomas D. Greer