LoadFile method of PDF viewer control not visible

2019-08-11 00:34发布

I wanted to automate filling of PDF forms.

So I created a WinForms project in VS2013, Added Adobe PDF Reader control, dragged control on to the form.

No errors. Control is displayed on the form.

However in the code of the form when I try to put in:

axAcroPDF1.LoadFile

The LoadFile method is not visible at all.

The project .NET target is set to 4.5.1. I even tried 4.5 and lower.

标签: c# pdf reader
1条回答
Luminary・发光体
2楼-- · 2019-08-11 00:49

The AxHost wraps only the Active X Control. The LoadFile Method is a method from the COM Class from your Adobe Control.

You need to implement this via a InvokeMember:

public void LoadFile(string path)
{
    this.GetOcx().GetType().InvokeMember("LoadFile", BindingFlags.InvokeMethod | 
      BindingFlags.OptionalParamBinding, null, this.GetOcx(), new object[1] { path });
}

where this is the AxHost control.

查看更多
登录 后发表回答