Skip to content

Commit a1f409c

Browse files
Merge pull request #3267 from syncfusion-content/1032401-textSearchBlazor
1032401: Text Search and Text Selection UG Documentation for Blazor PDF Viewer
2 parents 5a0c825 + afcac56 commit a1f409c

11 files changed

Lines changed: 604 additions & 195 deletions

Document-Processing-toc.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,18 @@
11411141
</ul>
11421142
</li>
11431143
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/magnification">Magnification</a></li>
1144-
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/text-search">Text Search</a></li>
1144+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/text-search/overview">Text Search</a>
1145+
<ul>
1146+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/text-search/text-search-features">Text Search</a></li>
1147+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/text-search/text-search-events">Text Search Events</a></li>
1148+
</ul>
1149+
</li>
1150+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/text-selection/overview">Text Selection</a>
1151+
<ul>
1152+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/text-selection/enable-text-selection">Toggle text selection</a></li>
1153+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/text-selection/text-selection-api-events">Text Selection API and Events</a></li>
1154+
</ul>
1155+
</li>
11451156
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/interaction">Interaction Mode</a></li>
11461157
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/hand-written-signature">Handwritten Signature</a></li>
11471158
<li>Annotations
26 KB
Loading
36.5 KB
Loading
15.7 KB
Loading

Document-Processing/PDF/PDF-Viewer/blazor/text-search.md

Lines changed: 0 additions & 194 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
layout: post
3+
title: Text search and Extraction in Blazor PDF Viewer | Syncfusion
4+
description: Overview of text search capabilities, UI features, programmatic APIs, events and text extraction in the Syncfusion Blazor PDF Viewer.
5+
platform: document-processing
6+
control: Text search
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Text search and extraction in Blazor PDF Viewer
12+
13+
The Blazor PDF Viewer provides an integrated text search experience that supports both interactive UI search and programmatic searches. Enable the feature by setting [`EnableTextSearch`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableTextSearch) as needed. To give more low-level information about text, methods like [`SearchTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchTextAsync_System_String_System_Boolean_) can be used.
14+
15+
The text search functionality allows you to retrieve and locate content within PDF documents with case-sensitive or case-insensitive matching, enabling integration with search analytics and downstream processing workflows.
16+
17+
## Key capabilities
18+
19+
- **Text search UI**: real‑time search from the toolbar, match‑case option, and search navigation controls.
20+
- **Text search programmatic APIs**: mirror UI behavior with [`SearchTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchTextAsync_System_String_System_Boolean_), [`SearchNextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchNextAsync), [`SearchPreviousAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchPreviousAsync), and [`CancelTextSearchAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_CancelTextSearchAsync).
21+
- **Text search events**: respond to [`OnTextSearchStart`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchStart), [`OnTextSearchHighlight`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchHighlight), and [`OnTextSearchComplete`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchComplete) for UI sync, analytics, and custom overlays.
22+
23+
## When to use which API
24+
25+
- Use the toolbar/search panel for typical interactive searches and navigation.
26+
- Use [`SearchTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchTextAsync_System_String_System_Boolean_) / [`SearchNextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchNextAsync) / [`SearchPreviousAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchPreviousAsync) when driving search programmatically but keeping behavior consistent with the UI.
27+
- Use [`OnTextSearchStart`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchStart), [`OnTextSearchHighlight`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchHighlight), and [`OnTextSearchComplete`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchComplete) events when you need to respond to search lifecycle changes for UI updates or logging.
28+
29+
## Further reading
30+
31+
- [Text Search Features](./text-search-features)
32+
- [Text Search Events](./text-search-events)
33+
- [Extract and Highlight Text in Blazor PDF Viewer Component](../faqs/how-to-extract-particular-text-and-highlight)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
layout: post
3+
title: Text search Events in Blazor PDF Viewer control | Syncfusion
4+
description: Learn how to handle text search events, and run programmatic searches in the Syncfusion Blazor PDF Viewer.
5+
platform: document-processing
6+
control: Text search
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Text Search Events in Blazor PDF Viewer
12+
13+
The Blazor PDF Viewer triggers events during text search operations, allowing you to customize behavior and respond to different stages of the search process.
14+
15+
## OnTextSearchStart
16+
17+
The [OnTextSearchStart](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchStart) event fires as soon as a search begins from the toolbar interface or through the [`SearchTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer2.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer2_SearchTextAsync_System_String_System_Boolean_) method. Use to reset UI state, log analytics, or cancel the default search flow before results are processed.
18+
19+
- Event arguments: [TextSearchStartEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.TextSearchStartEventArgs.html) exposes:
20+
- `SearchText`: the term being searched.
21+
- `MatchCase`: indicates whether case-sensitive search is enabled.
22+
23+
{% tabs %}
24+
{% highlight razor %}
25+
@using Syncfusion.Blazor.SfPdfViewer
26+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
27+
Height="100%"
28+
Width="100%">
29+
<PdfViewerEvents OnTextSearchStart="OnTextSearchStart"></PdfViewerEvents>
30+
</SfPdfViewer2>
31+
32+
@code {
33+
private void OnTextSearchStart(TextSearchStartEventArgs args)
34+
{
35+
Console.WriteLine($"Text search started for: \"{args.SearchText}\"");
36+
}
37+
}
38+
{% endhighlight %}
39+
{% endtabs %}
40+
41+
## OnTextSearchHighlight
42+
43+
The [OnTextSearchHighlight](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchHighlight) event triggers whenever a search result is brought into view, including navigation between matches. Use to draw custom overlays or synchronize adjacent UI elements when a match is highlighted.
44+
45+
- Event arguments: [TextSearchHighlightEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.TextSearchHighlightEventArgs.html) exposes:
46+
- `Bound`: represents the highlighted match position and dimensions.
47+
- `PageNumber`: page index where the match is highlighted.
48+
49+
{% tabs %}
50+
{% highlight razor %}
51+
@using Syncfusion.Blazor.SfPdfViewer
52+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
53+
Height="100%"
54+
Width="100%">
55+
<PdfViewerEvents OnTextSearchHighlight="OnTextSearchHighlight"></PdfViewerEvents>
56+
</SfPdfViewer2>
57+
58+
@code {
59+
private void OnTextSearchHighlight(TextSearchHighlightEventArgs args)
60+
{
61+
Console.WriteLine($"Highlighted match at page {args.PageNumber}, bounds: {args.Bound}");
62+
}
63+
}
64+
{% endhighlight %}
65+
{% endtabs %}
66+
67+
## OnTextSearchComplete
68+
69+
The [OnTextSearchComplete](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSearchComplete) event runs after the search engine finishes scanning the document for the current query. Use to update match counts, toggle navigation controls, or notify users when no results were found.
70+
71+
- **Typical uses**:
72+
- Update UI with the total number of matches and enable navigation controls.
73+
- Hide loading indicators or show a "no results" message if none were found.
74+
- Record analytics for search effectiveness.
75+
- **Event arguments**: [TextSearchCompleteEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.TextSearchCompleteEventArgs.html) exposes:
76+
- `SearchText`: the searched term.
77+
- `MatchCase`: indicates whether case-sensitive search was used.
78+
79+
{% tabs %}
80+
{% highlight razor %}
81+
@using Syncfusion.Blazor.SfPdfViewer
82+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
83+
Height="100%"
84+
Width="100%">
85+
<PdfViewerEvents OnTextSearchComplete="OnTextSearchComplete"></PdfViewerEvents>
86+
</SfPdfViewer2>
87+
88+
@code {
89+
private void OnTextSearchComplete(TextSearchCompleteEventArgs args)
90+
{
91+
Console.WriteLine($"Text search completed for: \"{args.SearchText}\"");
92+
}
93+
}
94+
{% endhighlight %}
95+
{% endtabs %}
96+
97+
## See Also
98+
99+
- [Text Search Features](./text-search-features)
100+
- [Text Selection](../text-selection/overview)
101+
- [Extract and Highlight Text in Blazor PDF Viewer Component](../faqs/how-to-extract-particular-text-and-highlight)

0 commit comments

Comments
 (0)