Skip to content

Commit afcac56

Browse files
1032401: Updated review changes
1 parent b93fda3 commit afcac56

3 files changed

Lines changed: 41 additions & 65 deletions

File tree

Document-Processing/PDF/PDF-Viewer/blazor/text-selection/enable-text-selection.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ domainurl: ##DomainURL##
1212

1313
This guide explains how to enable or disable text selection in the Syncfusion Blazor PDF Viewer using both initialization-time settings and runtime toggling.
1414

15-
**Outcome:** By the end of this guide, you will be able to control whether users can select text in the PDF Viewer.
16-
17-
## Steps to toggle text selection
18-
19-
### 1. Disable text selection at initialization
15+
### Disable text selection at initialization
2016

2117
Use the [EnableTextSelection](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableTextSelection) property during initialization to disable or enable text selection. The following example disables the text selection during initialization.
2218

@@ -35,7 +31,7 @@ Use the [EnableTextSelection](https://help.syncfusion.com/cr/blazor/Syncfusion.B
3531
{% endhighlight %}
3632
{% endtabs %}
3733

38-
### 2. Toggle text selection at runtime
34+
### Toggle text selection at runtime
3935

4036
The [EnableTextSelection](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableTextSelection) property can be toggled at runtime using buttons to enable or disable text selection dynamically. The following example demonstrates how to toggle text selection using button click events while also updating the [InteractionMode](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_InteractionMode) and reloading the document.
4137

@@ -84,10 +80,6 @@ The [EnableTextSelection](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazo
8480

8581
N> Text selection is enabled by default. Set `EnableTextSelection` to `false` to disable it.
8682

87-
## Troubleshooting
88-
89-
If text selection remains active, ensure that the [EnableTextSelection](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableTextSelection) property is set to `false`.
90-
9183
## See also
9284

9385
- [Text Selection API reference](./text-selection-api-events)

Document-Processing/PDF/PDF-Viewer/blazor/text-selection/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ The feature behaves consistently across single-page and multi-page documents.
2828

2929
## Copying text
3030

31-
Copying is available through several user interaction methods.
31+
You can copy selected text using the following options:
3232

3333
### Using the context menu
3434

35-
When text is selected, the built‑in context menu shows a Copy option. Selecting this option copies the highlighted text to the clipboard. See the [context menu](../context-menu/builtin-context-menu#text-menu-items) documentation for further explanation.
35+
When text is selected, the built‑in context menu shows a Copy option. Selecting this option copies the highlighted text to the clipboard. See the [context menu](../context-menu) documentation for further explanation.
3636

3737
### Using keyboard shortcuts
3838

Document-Processing/PDF/PDF-Viewer/blazor/text-selection/text-selection-api-events.md

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,9 @@ This document provides the reference details for text selection APIs and events
1616

1717
### SelectTextRegionAsync
1818

19-
Programmatically selects text within a specified page and bounds.
19+
The [SelectTextRegionAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_SelectTextRegionAsync_System_Int32_System_Collections_Generic_List_Syncfusion_Blazor_SfPdfViewer_Bound__) method programmatically selects text within a specified page and bounds. Use to highlight specific text regions based on user interactions, search results, or application logic.
2020

21-
**Method signature:**
22-
23-
```cshtml
24-
SelectTextRegionAsync(pageNumber: int, bounds: List<Bound>): Task
25-
```
26-
27-
**Parameters:**
28-
29-
- pageNumber: `int` indicating the target page (1 based indexing)
30-
- bounds: `List<Bound>` array defining the selection region
31-
32-
**Example:**
21+
The following example illustrates how to handle the SelectTextRegionAsync Method.
3322

3423
{% tabs %}
3524
{% highlight razor %}
@@ -50,38 +39,31 @@ SelectTextRegionAsync(pageNumber: int, bounds: List<Bound>): Task
5039
{
5140
List<Bound> bounds = new List<Bound>() {
5241
new Bound() {
53-
X= 349.312,
54-
Y= 372.32,
55-
Height= 32.3104,
56-
Width=100
57-
42+
X = 349.312,
43+
Y = 372.32,
44+
Height = 32.3104,
45+
Width = 100
5846
}
5947
};
60-
if(Viewer!=null)
61-
await Viewer.SelectTextRegionAsync(2, bounds);
48+
if(Viewer != null)
49+
await Viewer.SelectTextRegionAsync(2, bounds);
6250
}
6351
}
6452
{% endhighlight %}
6553
{% endtabs %}
6654

6755
### ClearTextSelectionAsync
6856

69-
Clears all text selection in the PDF document. Removes any highlighted or selected text regions.
70-
71-
**Method signature:**
72-
73-
```cshtml
74-
ClearTextSelectionAsync(): Task
75-
```
57+
The [ClearTextSelectionAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_ClearTextSelectionAsync) event clears all text selection in the PDF document. Removes any highlighted or selected text regions and resets the selection state. Use to reset the UI when users start a new operation or when clearing filtered results.
7658

77-
**Example:**
59+
The following example illustrates how to handle the ClearTextSelectionAsync Method.
7860

7961
{% tabs %}
8062
{% highlight razor %}
8163
@using Syncfusion.Blazor.SfPdfViewer
8264
@using Syncfusion.Blazor.Buttons
8365

84-
<SfButton OnClick="ClearTextSelection">ClearTextSelection</SfButton>
66+
<SfButton OnClick="ClearTextSelection">Clear Text Selection</SfButton>
8567
<SfPdfViewer2 Width="100%"
8668
Height="100%"
8769
DocumentPath="@DocumentPath"
@@ -93,8 +75,8 @@ ClearTextSelectionAsync(): Task
9375

9476
public async Task ClearTextSelection()
9577
{
96-
if(Viewer!=null)
97-
await Viewer.ClearTextSelectionAsync();
78+
if(Viewer != null)
79+
await Viewer.ClearTextSelectionAsync();
9880
}
9981
}
10082
{% endhighlight %}
@@ -104,65 +86,67 @@ ClearTextSelectionAsync(): Task
10486

10587
### OnTextSelectionStart
10688

107-
Triggered when the user begins selecting text.
89+
The [OnTextSlectionStart](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSelectionStart) event is triggered when the user begins selecting text. Use to perform actions when text selection starts, such as logging, updating UI elements, or starting data collection.
90+
91+
- Event arguments: [TextSelectionStartEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.TextSelectionStartEventArgs.html) exposes:
92+
- `PageNumber` - The page where the selection started (1‑based indexing).
93+
94+
The following example illustrates how to handle the OnTextSelectionStart event.
10895

10996
{% tabs %}
11097
{% highlight razor %}
11198
@using Syncfusion.Blazor.SfPdfViewer
112-
<SfPdfViewer2 DocumentPath="@DocumentPath">
99+
100+
<SfPdfViewer2 Width="100%"
101+
Height="100%"
102+
DocumentPath="@DocumentPath">
113103
<PdfViewerEvents OnTextSelectionStart="OnTextSelectionStart"></PdfViewerEvents>
114104
</SfPdfViewer2>
115105

116106
@code {
117107
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
108+
118109
private void OnTextSelectionStart(TextSelectionStartEventArgs args)
119110
{
120-
// PageNumber - The page where the selection started (1‑based indexing)
121111
int pageNumber = args.PageNumber;
122-
Console.WriteLine(pageNumber);
112+
Console.WriteLine($"Text selection started on page: {pageNumber}");
123113
}
124114
}
125115
{% endhighlight %}
126116
{% endtabs %}
127117

128-
**Arguments include:**
118+
### OnTextSelectionEnd
129119

130-
- `PageNumber` - The page where the selection started (1‑based indexing).
120+
The [OnTextSlectionEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_OnTextSelectionEnd) event is triggered when the selection operation completes. Use to capture and process selected text, update UI elements, or perform operations based on the selection bounds and content.
131121

132-
### OnTextSelectionEnd
122+
- Event arguments: [TextSelectionEndEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.TextSelectionEndEventArgs.html) exposes:
123+
- `TextBounds` - Defines the bounds of the selected text in the page.
124+
- `TextContent` - Defines the text content selected in the page.
133125

134-
Triggered when the selection operation completes.
126+
The following example illustrates how to handle the OnTextSelectionEnd Event.
135127

136128
{% tabs %}
137129
{% highlight razor %}
138-
<SfPdfViewer2 DocumentPath="@DocumentPath">
130+
@using Syncfusion.Blazor.SfPdfViewer
131+
132+
<SfPdfViewer2 Width="100%"
133+
Height="100%"
134+
DocumentPath="@DocumentPath">
139135
<PdfViewerEvents OnTextSelectionEnd="OnTextSelectionEnd"></PdfViewerEvents>
140136
</SfPdfViewer2>
141137

142138
@code {
143139
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
140+
144141
private void OnTextSelectionEnd(TextSelectionEndEventArgs args)
145142
{
146-
// PageNumber - Page where the selection ended (1‑based indexing)
147-
int pageNumber = args.PageNumber;
148-
Console.WriteLine(pageNumber);
149-
// TextContent - The full text extracted from the selection range
150143
string textContent = args.TextContent;
151-
Console.WriteLine(textContent);
152-
// TextBounds - Array of bounding rectangles that define the geometric region of the selected text
153144
List<TextBound> textBounds = args.TextBounds;
154-
Console.WriteLine(textBounds);
155145
}
156146
}
157147
{% endhighlight %}
158148
{% endtabs %}
159149

160-
**Arguments include:**
161-
162-
- `PageNumber` - Page where the selection ended (1‑based indexing).
163-
- `TextContent` - The full text extracted from the selection range.
164-
- `TextBounds` - Array of bounding rectangles that define the geometric region of the selected text. Useful for custom UI overlays or programmatic re-selection.
165-
166150
## See also
167151

168152
- [Toggle text selection](./enable-text-selection)

0 commit comments

Comments
 (0)