I'm trying to automate Acrobat using C#. I'm using in particular Acrobat 6.0 Professional.
I add the Acrobat object via .NET COM Interop. I can create the App, AVDoc, and PDDoc objects:
Now, I want to open a document, and save it as text. Should be simple enough, however, two problems: opening a document with the PDDoc's "Open" method always fails. Second, there is no "SaveAs()" method!
Futher digging reveals that the JavaScript engine does have a SaveAs method. Ok, I'll use that. Hmm, how to get the JSObject? Oh look, PDDoc has a handy "GetJSObject()" method. However, it returns just a generic "Object", so I can't box it or cast it to anything useful in C#.
Does anyone have any idea how to perform a SaveAs with Acrobat IAC in C#?
Or, does Acrobat 7.0 do this? Can anyone PROVE it with a working example, before I shell out for 7.0? Documentation alone won't do it; I'm afraid I have very little faith in Adobe's APIs.
Thomas D. Greer
I add the Acrobat object via .NET COM Interop. I can create the App, AVDoc, and PDDoc objects:
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);
Now, I want to open a document, and save it as text. Should be simple enough, however, two problems: opening a document with the PDDoc's "Open" method always fails. Second, there is no "SaveAs()" method!
Futher digging reveals that the JavaScript engine does have a SaveAs method. Ok, I'll use that. Hmm, how to get the JSObject? Oh look, PDDoc has a handy "GetJSObject()" method. However, it returns just a generic "Object", so I can't box it or cast it to anything useful in C#.
Does anyone have any idea how to perform a SaveAs with Acrobat IAC in C#?
Or, does Acrobat 7.0 do this? Can anyone PROVE it with a working example, before I shell out for 7.0? Documentation alone won't do it; I'm afraid I have very little faith in Adobe's APIs.
Thomas D. Greer