问题:
I have an application that is similar to the SDK sample application FillFormCS. I just upgraded from Acrobat 7.0 Pro to Acrobat 9.0 Pro. Both my app and FillFormCS worked with 7.0, but with 9.0 they give me the same exception: "No document is currently open in the Acrobat Viewer".
The problem seems to be connected to the avDoc's Open() and OpeninWindowEx() functions. The document never really seems to get opened.
Can anyone tell me if FillFormCS is supposed to run correctly with Acrobat 9.0 Pro when built from Visual Studio 2008? Visual Studio upgraded the solution and source files automatically. The references to the type library and ActiveX control seem fine.
If the problem is with VS 2008, can anyone suggest what I could do since VS 2005 isn't an option?
Thanks for any help you can give me.
The problem seems to be connected to the avDoc's Open() and OpeninWindowEx() functions. The document never really seems to get opened.
Can anyone tell me if FillFormCS is supposed to run correctly with Acrobat 9.0 Pro when built from Visual Studio 2008? Visual Studio upgraded the solution and source files automatically. The references to the type library and ActiveX control seem fine.
If the problem is with VS 2008, can anyone suggest what I could do since VS 2005 isn't an option?
Thanks for any help you can give me.
答案:
OK, I have an answer, after more than two weeks and finally spending $200 for Developer Support, it turns out that for Acrobat 9.0, you have to call Show() after the Open(), not before, to get everything to work right. Here's a snippet of FillFormCS.cs that works:
static void Main(string[] args)
{
String FORM_NAME = Application.StartupPath + "//SampleForm.pdf";
// Initialize Acrobat by cretaing App object.
CAcroApp acroApp = new AcroAppClass();
// Show Acrobat Viewer: Don't do this before the Open()!
//acroApp.Show();
// Create an AVDoc object
CAcroAVDoc avDoc = new AcroAVDocClass();
// Open the pdf
if(avDoc.Open (FORM_NAME, "") == false)
{
string szMsg = "Cannot open " + FORM_NAME + "./n";
//Console.WriteLine(szMsg);
MessageBox.Show("Cannot open " + FORM_NAME);
return;
}
// Show Acrobat Viewer: Now you can do it.
acroApp.Show();
// Create a IAFormApp object, so that we can access the form fields in
// the open document
IAFormApp formApp = new AFormAppClass();
Also, if you want to use OpenInWindowEx() rather than Open(), you have to be sure to Lock() before you open and UnlockEx() after.
Good luck.
static void Main(string[] args)
{
String FORM_NAME = Application.StartupPath + "//SampleForm.pdf";
// Initialize Acrobat by cretaing App object.
CAcroApp acroApp = new AcroAppClass();
// Show Acrobat Viewer: Don't do this before the Open()!
//acroApp.Show();
// Create an AVDoc object
CAcroAVDoc avDoc = new AcroAVDocClass();
// Open the pdf
if(avDoc.Open (FORM_NAME, "") == false)
{
string szMsg = "Cannot open " + FORM_NAME + "./n";
//Console.WriteLine(szMsg);
MessageBox.Show("Cannot open " + FORM_NAME);
return;
}
// Show Acrobat Viewer: Now you can do it.
acroApp.Show();
// Create a IAFormApp object, so that we can access the form fields in
// the open document
IAFormApp formApp = new AFormAppClass();
Also, if you want to use OpenInWindowEx() rather than Open(), you have to be sure to Lock() before you open and UnlockEx() after.
Good luck.