Skip to content

Commit f645e5e

Browse files
1010724: Updated Text Markup Annotation
1 parent d8ae7cd commit f645e5e

5 files changed

Lines changed: 883 additions & 73 deletions

File tree

Document-Processing-toc.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,14 @@
956956
<li><a href="/document-processing/pdf/pdf-viewer/react/text-search">Text Search</a></li>
957957
<li>Annotation
958958
<ul>
959+
<li>Annotation Types
960+
<ul>
961+
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/annotation-types/highlight-annotation">Highlight</a></li>
962+
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/annotation-types/underline-annotation">Underline</a></li>
963+
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/annotation-types/strikethrough-annotation">Strikethrough</a></li>
964+
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/annotation-types/squiggly-annotation">Squiggly</a></li>
965+
</ul>
966+
</li>
959967
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/text-markup-annotation">Text Markup Annotation</a></li>
960968
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/shape-annotation">Shape Annotation</a></li>
961969
<li><a href="/document-processing/pdf/pdf-viewer/react/annotation/stamp-annotation">Stamp Annotation</a></li>

Document-Processing/PDF/PDF-Viewer/react/annotation/annotation-types/highlight-annotation.md

Lines changed: 69 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ To enable Highlight annotations, inject the following modules into the React PDF
2121

2222
- [**Annotation**](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#annotation)
2323
- [**TextSelection**](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#textselection)
24-
- [**TextSearch**](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#textsearch)
2524
- [**Toolbar**](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#toolbar)
2625

2726
This minimal setup enables UI interactions like selection and highlighting.
@@ -36,8 +35,7 @@ import {
3635
Inject,
3736
Toolbar,
3837
Annotation,
39-
TextSelection,
40-
TextSearch
38+
TextSelection
4139
} from '@syncfusion/ej2-react-pdfviewer';
4240

4341
function App() {
@@ -48,7 +46,7 @@ function App() {
4846
resourceUrl="https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib"
4947
style={{ height: '650px' }}
5048
>
51-
<Inject services={[Toolbar, Annotation, TextSelection, TextSearch]} />
49+
<Inject services={[Toolbar, Annotation, TextSelection]} />
5250
</PdfViewerComponent>
5351
);
5452
}
@@ -60,7 +58,9 @@ ReactDOM.createRoot(document.getElementById('sample')).render(<App />);
6058

6159
---
6260

63-
## Apply Highlight Using the Toolbar
61+
## Apply Highlight Annotation
62+
63+
### Apply Highlight Using the Toolbar
6464

6565
1. Select the text you want to highlight.
6666
2. Click the **Highlight** icon in the annotation toolbar.
@@ -70,7 +70,17 @@ ReactDOM.createRoot(document.getElementById('sample')).render(<App />);
7070

7171
---
7272

73-
## Apply Highlight Programmatically
73+
### Apply highlight using Context Menu
74+
75+
Right-click a selected text region → select **Highlight**.
76+
77+
![Highlight Context](../../../javascript-es6/annotations/annotation-images/highlight-context.gif)
78+
79+
To customize menu items, refer to [**Customize Context Menu**](../../context-menu/custom-context-menu) documentation.
80+
81+
---
82+
83+
### Enable Highlight Mode
7484

7585
Switch the viewer into highlight mode using `setAnnotationMode('Highlight')`.
7686

@@ -85,7 +95,7 @@ function enableHighlight() {
8595
{% endhighlight %}
8696
{% endtabs %}
8797

88-
### Exit Highlight Mode
98+
#### Exit Highlight Mode
8999

90100
Switch back to normal mode using:
91101

@@ -100,7 +110,9 @@ function disableHighlightMode() {
100110
{% endhighlight %}
101111
{% endtabs %}
102112

103-
### Add Highlight Programmatically (with bounds)
113+
---
114+
115+
### Add Highlight Programmatically
104116

105117
Use [`addAnnotation()`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#addannotation) to insert highlight at a specific location.
106118

@@ -119,38 +131,6 @@ function addHighlight() {
119131
{% endhighlight %}
120132
{% endtabs %}
121133

122-
123-
## Add Multiple Highlights with Individual Properties
124-
You can also supply custom per‑annotation settings:
125-
126-
{% tabs %}
127-
{% highlight js tabtitle="Standalone" %}
128-
{% raw %}
129-
function addMultipleHighlights() {
130-
const viewer = document.getElementById('container').ej2_instances[0];
131-
132-
// Highlight 1
133-
viewer.annotation.addAnnotation('Highlight', {
134-
bounds: [{ x: 100, y: 150, width: 320, height: 14 }],
135-
pageNumber: 1,
136-
author: 'User 1',
137-
color: '#ffff00',
138-
opacity: 0.9
139-
});
140-
141-
// Highlight 2
142-
viewer.annotation.addAnnotation('Highlight', {
143-
bounds: [{ x: 110, y: 220, width: 300, height: 14 }],
144-
pageNumber: 1,
145-
author: 'User 2',
146-
color: '#ff1010',
147-
opacity: 0.9
148-
});
149-
}
150-
{% endraw %}
151-
{% endhighlight %}
152-
{% endtabs %}
153-
154134
---
155135

156136
## Customize Highlight Appearance
@@ -172,7 +152,7 @@ Configure default highlight settings such as **color**, **opacity**, and **autho
172152
opacity: 0.9
173153
}}
174154
>
175-
<Inject services={[Toolbar, Annotation, TextSelection, TextSearch]} />
155+
<Inject services={[Toolbar, Annotation, TextSelection]} />
176156
</PdfViewerComponent>
177157
{% endraw %}
178158
{% endhighlight %}
@@ -182,7 +162,10 @@ Configure default highlight settings such as **color**, **opacity**, and **autho
182162

183163
## Manage Highlight (Edit, Delete, Comment)
184164

185-
### Edit Highlight Appearance (UI)
165+
### Edit Highlight
166+
167+
#### Edit Highlight Appearance (UI)
168+
186169
Use the annotation toolbar:
187170
- **Edit Color** tool
188171
![Edit color](../../../javascript-es6/images/edit_color.png)
@@ -192,15 +175,7 @@ Use the annotation toolbar:
192175

193176
---
194177

195-
### Delete Highlight
196-
- Press **Delete** key, or
197-
- Use **Delete Annotation** in the toolbar
198-
199-
![Delete Highlight](../../../javascript-es6/images/delete_button.png)
200-
201-
---
202-
203-
### Edit Highlight Programmatically
178+
#### Edit Highlight Programmatically
204179

205180
Modify an existing highlight programmatically using `editAnnotation()`.
206181

@@ -225,45 +200,56 @@ function editHighlightProgrammatically() {
225200

226201
---
227202

228-
### Comments
229-
Use the [**Comments panel**](../comments) for threaded discussions on highlight annotations.
230-
231-
---
203+
### Delete Highlight
232204

233-
## Use the Context Menu with Highlight
205+
The PDF Viewer supports deleting existing annotations through both the UI and API.
206+
For detailed behavior, supported deletion workflows, and API reference, see [Delete Annotation](../remove-annotations)
234207

235-
Right-click a selected text region → select **Highlight**.
208+
---
236209

237-
![Highlight Context](../../../javascript-es6/annotations/annotation-images/highlight-context.gif)
210+
### Comments
238211

239-
To customize menu items, refer to [**Customize Context Menu**](../../context-menu/custom-context-menu) documentation.
212+
Use the [Comments panel](../comments) to add, view, and reply to threaded discussions linked to underline annotations.
213+
It provides a dedicated UI for reviewing feedback, tracking conversations, and collaborating on annotation‑related notes within the PDF Viewer.
240214

241215
---
242216

243-
## Handle Highlight Events
217+
## Set properties while adding Individual Annotation
244218

245-
Subscribe to annotation lifecycle events.
219+
Set properties for individual annotation before creating the control using [highlightSettings](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#highlightsettings)
246220

247221
{% tabs %}
248222
{% highlight js tabtitle="Standalone" %}
249223
{% raw %}
250-
function onAnnotationAdd(args) {
251-
console.log('Highlight added:', args);
252-
}
224+
function addMultipleHighlights() {
225+
const viewer = document.getElementById('container').ej2_instances[0];
253226

254-
<PdfViewerComponent
255-
id="container"
256-
annotationAdd={onAnnotationAdd}
257-
/>
227+
// Highlight 1
228+
viewer.annotation.addAnnotation('Highlight', {
229+
bounds: [{ x: 100, y: 150, width: 320, height: 14 }],
230+
pageNumber: 1,
231+
author: 'User 1',
232+
color: '#ffff00',
233+
opacity: 0.9
234+
});
235+
236+
// Highlight 2
237+
viewer.annotation.addAnnotation('Highlight', {
238+
bounds: [{ x: 110, y: 220, width: 300, height: 14 }],
239+
pageNumber: 1,
240+
author: 'User 2',
241+
color: '#ff1010',
242+
opacity: 0.9
243+
});
244+
}
258245
{% endraw %}
259246
{% endhighlight %}
260247
{% endtabs %}
261248

262-
See [**Annotation Events**](../annotation-event) page for full list and parameter details.
263-
264249
---
265250

266251
## Disable TextMarkup Annotation
252+
267253
Disable text markup annotations (including highlight) using the [`enableTextMarkupAnnotation`](https://ej2.syncfusion.com/react/documentation/api/pdfviewer/index-default#enabletextmarkupannotation) property.
268254

269255
{% tabs %}
@@ -276,17 +262,25 @@ Disable text markup annotations (including highlight) using the [`enableTextMark
276262
resourceUrl="https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib"
277263
style={{ height: '650px' }}
278264
>
279-
<Inject services={[Toolbar, Annotation, TextSelection, TextSearch]} />
265+
<Inject services={[Toolbar, Annotation, TextSelection]} />
280266
</PdfViewerComponent>
281267
{% endraw %}
282268
{% endhighlight %}
283269
{% endtabs %}
284270

285271
---
286272

287-
## Save and Export
273+
## Handle Highlight Events
274+
275+
The PDF viewer provides annotation life-cycle events that notify when highlight annotations are added, modified, selected, or removed.
276+
For the full list of available events and their descriptions, see [**Annotation Events**](../annotation-event)
277+
278+
---
279+
280+
## Export and Import
288281

289-
Use the [**Download**](../../download) tool to export the PDF with highlight annotations included. The original document remains unchanged.
282+
The PDF Viewer supports exporting and importing annotations, allowing you to save annotations as a separate file or load existing annotations back into the viewer.
283+
For full details on supported formats and steps to export or import annotations, see [Export and Import Annotation](../export-import-annotations)
290284

291285
---
292286

@@ -296,3 +290,5 @@ Use the [**Download**](../../download) tool to export the PDF with highlight ann
296290
- [Customize Context Menu](../../context-menu/custom-context-menu)
297291
- [Comments Panel](../comments)
298292
- [Annotation Events](../annotation-event)
293+
- [Export and Import annotations](../export-import-annotations)
294+
- [Delete Annotations](../remove-annotations)

0 commit comments

Comments
 (0)