PDFDocumentSource allows you to implement text search in a PDF file by matching the search criteria and examining all the words stored in the file through C1TextSearchManager class, member of C1.WPF.Document namespace. The class provides various methods, such as FindStart to find the first occurrence, FindNext to find the next occurrence, and FindPrevious to find the previous occurrence of the searched text. You can use C1FindTextParams(string text, bool wholeWord, bool matchCase) method to initialize a new instance of C1FindTextParams class with the following parameters:
The following image shows the word searched in a PDF file and the list of matches as search results.
In this sample code, we use the FindStart method on the C1TextSearchManager to find instances of the search text.
XAML |
Copy Code
|
---|---|
<ListView x:Name="listView1" HorizontalAlignment="Left" Height="203" Margin="10,106,0,0" VerticalAlignment="Top" Width="497"> <ListView.View> <GridView> <GridViewColumn Header="#" x:Name="chNum" Width="50" DisplayMemberBinding="{Binding ID}" /> <GridViewColumn Header="Page" x:Name="chPage" Width="60" DisplayMemberBinding="{Binding Page}"/> <GridViewColumn Header="Bounds" x:Name="chBounds" Width="100" DisplayMemberBinding="{Binding Bounds}"/> <GridViewColumn Header="Position in Near Text" x:Name="chPosInNearText" Width="60" DisplayMemberBinding="{Binding Position}"/> <GridViewColumn Header="Near Text" x:Name="chNearText" Width="350" DisplayMemberBinding="{Binding NearText}"/> </GridView> </ListView.View> </ListView> |