问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/31859466/loadfile-method-of-pdf-viewer-control-not-visible