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

Scroll document when searching

1 Answer 91 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Christie Admin
Top achievements
Rank 1
Christie Admin asked on 07 Nov 2014, 08:21 PM
Hi,

I implemented a search functionality with the PDF Viewer control. The user have the flexibility to do a findfirst, findlast, findprior, findnext and depending on what the user did, I highlight the searchtext corresponding on which action the user did. I would like to know how to scroll to the matching text I found to have it in the visible portion of the viewer.

Thank's
Alain

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 10 Nov 2014, 01:14 PM
Hello Alain,

Thank you for contacting us.

You can use RadFixedDocument's CaretPosition and move it to the position of the search result. The following code snippet shows how to find some text in RadPdfViewer, scroll to the search result and select the found text.
SearchResult searchResult = this.pdfViewer.Find(searchText);
 
if (searchResult != SearchResult.NotFound)
{
    this.pdfViewer.Document.CaretPosition.MoveToPosition(searchResult.Range.StartPosition);
    this.pdfViewer.Select(searchResult.Range);
}

For more information about text positions you may follow this link to TextPosition documentation article.
 
I hope this is helpful. If you have any other question or concerns please do not hesitate to contact us again.

Regards,
Deyan
the Telerik team
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PDFViewer
Asked by
Christie Admin
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or