This is a migrated thread and some comments may be shown as answers.

Navigator can find the text, but not Find function

2 Answers 101 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 19 Jan 2016, 09:53 PM

Greetings,

I am attempting to search a loaded PDF document for a specific bit of text which can be located via the navigator controls but the PdfViewerElement.Find isn't able to find it.

 I have included my code below which I got from the online documentation and you can see the pdf I am searching at this address http://ab.rockwellautomation.com/Programmable-Controllers/MicroLogix-1100#documentation

 Is there something I am doing wrong in my code that the PDFNavigators search function can locate text but mine cannot?

 

Thank you!

Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim opt As New Telerik.Windows.Pdf.Documents.Fixed.Search.TextSearchOptions
 
    DaViewer.LoadDocument("C:\Users\Sean\Desktop\1763-um001_-en-p.pdf")
 
    opt.CaseSensitive = False
    opt.WholeWordsOnly = False
 
    Dim res As Telerik.Windows.Pdf.Documents.Fixed.Search.SearchResult = DaViewer.PdfViewerElement.Find("Allen", opt)
 
    If res Is Telerik.Windows.Pdf.Documents.Fixed.Search.SearchResult.NotFound Then
        RadMessageBox.Show("String not found")
    Else
        RadMessageBox.Show("Result found on page " & res.Range.StartPosition.Page.PageNo)
    End If
End Sub

2 Answers, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 1
answered on 19 Jan 2016, 11:25 PM
Nevermind,  I forgot to wait for the document to load fully.  After it was loaded everything worked just find.  
0
Hristo
Telerik team
answered on 20 Jan 2016, 03:44 PM
Hi Sean,

Thank you for writing.

I am glad that you have resolved the issue. The process of loading a document in RadPdfViewer is an asynchronous operation which varies in time for the different documents. 

Before we perform any manipulation, we should make sure that the document has been loaded successfully. RadPdfViewer exposes the DocumentLoaded event for this kind of notification: http://docs.telerik.com/devtools/winforms/pdfviewer/getting-started.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
PdfViewer and PdfViewerNavigator
Asked by
Sean
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or