You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Viewer/react/how-to/enable-text-selection.md
+99-88Lines changed: 99 additions & 88 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,122 +8,133 @@ documentation: ug
8
8
domainurl: ##DomainURL##
9
9
---
10
10
11
-
# Enable or disable text selection in PDF Viewer
11
+
# Enable or disable text selection in React PDF Viewer
12
12
13
-
The Syncfusion PDF Viewer exposes the `enableTextSelection` property to control whether users can select text within the displayed PDF document. This setting can be configured at initializationand toggled programmatically at runtime.
13
+
This guide explains how to enable or disable text selection in the Syncfusion React PDF Viewer using both initialization-time settings and runtime toggling.
14
14
15
-
## Configure text selection on initialization
15
+
**Outcome:** By the end of this guide, you will be able to control whether users can select text in the PDF Viewer.
16
16
17
-
Set the initial text-selection behavior by configuring the `enableTextSelection` property in the component template or on the `PdfViewerComponent` instance. The example below shows a complete component (TypeScript and template) that initializes the viewer with text selection disabled.
17
+
## Steps to toggle text selection
18
18
19
-
{% tabs %}
20
-
{% highlight js tabtitle="Standalone" %}
19
+
### 1. Disable text selection at initialization
20
+
21
+
Follow one of these steps to disable text selection when the viewer first loads:
22
+
23
+
**Remove the text selection module**
24
+
25
+
Remove the [`TextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/textselection) module in the services array to disable text selection during initialization.
Use the [`enableTextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enabletextselection) during initialization to disable or enable text selection. The following example disables the text selection during initialization
Change the behavior at runtime using buttons or other UI.
72
+
The [`enableTextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enabletextselection) property can also be used to toggle the text selection at runtime.
N> When text selection is disabled, the viewer automatically switches to pan mode.
122
+
123
+
[View sample in GitHub](https://github.com/SyncfusionExamples/react-pdf-viewer-examples/tree/master/How%20to)
124
+
119
125
## Use cases and considerations
120
126
121
127
- Document protection: Disable text selection to help prevent copying sensitive content.
122
128
- Read-only documents: Provide a cleaner viewing experience by preventing selection.
123
129
- Interactive apps: Toggle selection based on user roles or document states.
124
130
125
-
## Default behavior
131
+
N> Text selection is enabled by default. Set `enableTextSelection` to `false` to disable it.
132
+
133
+
## Troubleshooting
134
+
135
+
If text selection remains active, ensure that the [`TextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/textselection) is removed in `Inject` or [`enableTextSelection`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer#enabletextselection) is set to `false`.
126
136
127
-
Text selection is enabled by default. Set `enableTextSelection` to `false` to disable it.
137
+
## See also
128
138
129
-
[View sample in GitHub](https://github.com/SyncfusionExamples/react-pdf-viewer-examples/tree/master/How%20to)
139
+
-[Text Selection API reference](../text-selection/reference)
title: Text selection in React PDF Viewer | Syncfusion
4
+
description: Learn the text selection concepts, copy behavior, and interaction capabilities of the Syncfusion React PDF Viewer.
5
+
platform: document-processing
6
+
control: Text selection
7
+
documentation: ug
8
+
domainurl: ##DomainURL##
9
+
---
10
+
11
+
# Text selection in React PDF Viewer
12
+
13
+
The Text Selection module in the Syncfusion React PDF Viewer enables users to select and copy text from a loaded PDF document. Text selection is available by default and gives users direct interaction with the content through dragging, keyboard shortcuts, and context menus.
14
+
15
+
This overview explains the behavior of text selection, how copy actions work, and how it relates to other interaction features in the viewer.
16
+
17
+
## Capabilities of text selection
18
+
19
+
Text selection allows users to:
20
+
21
+
- Highlight text using mouse or touch
22
+
- Copy the selected text to the clipboard
23
+
- Access contextual commands such as Copy through the built‑in context menu
24
+
- Use keyboard shortcuts such as Ctrl+C or Cmd+C to copy text
25
+
- Trigger application behavior through selection events
26
+
27
+
The feature behaves consistently across single-page and multi-page documents.
28
+
29
+
## Copying text
30
+
31
+
Copying is available through several user interaction methods.
32
+
33
+
### Using the context menu
34
+
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.
36
+
37
+
### Using keyboard shortcuts
38
+
39
+
The following keyboard shortcuts copy the selected text:
40
+
41
+
- Ctrl+C (Windows and Linux)
42
+
- Cmd+C (macOS)
43
+
44
+
## Related topics
45
+
46
+
These topics describe how selection interacts with other features or how copy behavior may be limited depending on viewer configuration or PDF security settings.
0 commit comments