简体   繁体   English

我们如何使用C#在AxAcroPDFLib.AxAcroPDF(Pdf)中实现搜索功能

[英]How Can we implement search functionality in AxAcroPDFLib.AxAcroPDF( Pdf ) using C#

I am using the AxAcroPDFLib.AxAcroPDF library to Display the files in the winforms Control using the line, 我正在使用AxAcroPDFLib.AxAcroPDF库使用该行在winforms控件中显示文件,

AxAcroPDFLib.AxAcroPDF.src = path;

It's loaded the file well and when we click CTRL+F it showing search box and searching the searched string well. 它已很好地加载了文件,当我们单击CTRL + F时,它会显示搜索框并很好地搜索搜索到的字符串。

But we need to implement the search functionality programatically using the Dotnet Code to automatically search the string in pdf file. 但是我们需要使用Dotnet代码以编程方式实现搜索功能,以自动搜索pdf文件中的字符串。

To do so I didn't find any supported methods to find the string programatically. 为此,我没有找到任何受支持的方法来以编程方式查找字符串。

Please provide the solution to implement the search functionality in PDF files. 请提供解决方案以实现PDF文件中的搜索功能。

As best I have been able to figure out, this ActiveX control does not implement a text search function. 尽我所能发现,此ActiveX控件未实现文本搜索功能。 As a workaround, which is kind of a kludge but adequate for what I wanted: assuming you have declared the control as a AxAcroPDFLib.AxAcroPDF object, say pdfFoo, first select the control, then use SendKeys.Send to do the text search, something like (this is VB, but C# should work the same): 作为一种变通办法,这有点麻烦,但足以满足我的需要:假设您已将控件声明为AxAcroPDFLib.AxAcroPDF对象,例如pdfFoo,首先选择控件,然后使用SendKeys.Send进行文本搜索,就像(这是VB,但C#的工作原理相同):

pdfFoo.Select()
SendKeys.Send("^f")  'send control-f to get search box
SendKeys.Flush()
SendKeys.Send("text to search for")
SendKeys.Flush()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM