FillFormCS sample and Acrobat 9.0 Pro Error:"No document is currently open in the Acrobat Viewer"

问题:

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.
答案:
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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值