我需要显示webbrowser控件中显示的pdf文档中的Selected文本 [英] I need To show the Selected text from a pdf document shown in a webbrowser control
问题描述
我需要显示vb.net windows应用程序中webbrowser控件中显示的pdf文档中的Selected文本。
i尝试下面的代码,但选择的文件是null alwasys
WebBrowser1.Navigate(D:\\ \\ Madad \Documents\Excel-3-Formulas-and-Functions.pdf)
Dim doc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
Dim currentSelection as mshtml.IHTMLSelectionObject = doc.selection
如果currentSelection IsNot Nothing那么
昏暗范围作为mshtml。 IHTMLTxtRange = currentSelection.createRange
如果范围IsNot Nothing那么
MessageBox.Show(range.text)
结束如果
结束如果
是的,它即将结束。您没有给用户任何时间选择任何东西!
您的代码导航到文档然后立即尝试使用尚不存在的选择!
I need To show the Selected text from a pdf document shown in a webbrowser control in vb.net windows application.
i tried following code but selected document is coming null alwasys
WebBrowser1.Navigate("D:\Madhu\Documents\Excel-3-Formulas-and-Functions.pdf")
Dim doc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
Dim currentSelection As mshtml.IHTMLSelectionObject = doc.selection
If currentSelection IsNot Nothing Then
Dim range As mshtml.IHTMLTxtRange = currentSelection.createRange
If range IsNot Nothing Then
MessageBox.Show(range.text)
End If
End If
Yeah, it's coming up null. You haven't given the user any time to select anything!
Your code is navigating to a document and then immediately trying to use a selection that doesn't exist yet!
这篇关于我需要显示webbrowser控件中显示的pdf文档中的Selected文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!