LoadFile method of PDF viewer control not visible

吃可爱长大的小学妹 提交于 2019-12-13 01:27:25

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!