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
title: Custom annotation tools in React PDF Viewer | Syncfusion
4
-
description: Learn how to build a custom toolbar for Syncfusion React PDF Viewer and switch annotation tools programmatically using setAnnotationMode.
3
+
title: Custom annotation tools in Angular PDF Viewer | Syncfusion
4
+
description: Learn how to build a custom toolbar for Syncfusion Angular PDF Viewer and switch annotation tools programmatically using setAnnotationMode.
5
5
platform: document-processing
6
6
control: PDF Viewer
7
7
documentation: ug
8
8
domainurl: ##DomainURL##
9
9
---
10
10
11
-
# Custom annotation tools in React PDF Viewer
11
+
# Custom annotation tools in Angular PDF Viewer
12
12
13
13
The PDF Viewer supports adding a custom toolbar and toggling annotation tools programmatically using the `setAnnotationMode` method. The viewer can enable tools such as Highlight, Underline, Rectangle, Circle, Arrow, Free Text, Ink, and measurement annotations (Distance, Perimeter, Area, Radius)
14
14
15
15
Follow these steps to build a minimal custom annotation toolbar.
16
16
17
17
Step 1: Start from a basic PDF Viewer sample
18
18
19
-
Refer to the [Getting started guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/react/getting-started) to create a basic sample.
19
+
Refer to the [Getting started guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/angular/getting-started) to create a basic sample.
20
20
21
-
Step 2: Add a lightweight custom toolbar with React buttons
21
+
Step 2: Add a lightweight custom toolbar with Angular buttons
22
22
23
-
Add buttons for the tools to expose. The sample below uses plain React buttons for simplicity; replace with a Syncfusion ToolbarComponent for a richer UI if desired.
23
+
Add buttons for the tools to expose. The sample below uses plain Angular buttons for simplicity; replace with a Syncfusion ToolbarComponent for a richer UI if desired.
24
24
25
25
Step 3: Import and inject modules
26
26
27
27
Ensure the `Annotation` module is injected. Include text selection and search modules if those capabilities are required.
28
28
29
29
{% tabs %}
30
-
{% highlight js tabtitle="Standalone" %}
31
-
{% raw %}
32
-
import * as React from 'react';
33
-
import * as ReactDOM from 'react-dom/client';
34
-
import { PdfViewerComponent, Inject, Toolbar, Annotation, TextSelection } from '@syncfusion/ej2-react-pdfviewer';
35
-
36
-
function getViewer() { return document.getElementById('container').ej2_instances[0]; }
37
-
38
-
function setMode(mode) { getViewer().annotation.setAnnotationMode(mode); }
## Custom tools using Syncfusion Toolbar for a richer UI
79
82
80
-
Replace the plain buttons with a Syncfusion `ToolbarComponent` and icons for a richer UI. Add the `@syncfusion/ej2-react-navigations` package and wire each item's `clicked` handler to `setAnnotationMode`.
83
+
Replace the plain buttons with a Syncfusion `ToolbarComponent` and icons for a richer UI. Add the `@syncfusion/ej2-angular-navigations` package and wire each item's `clicked` handler to `setAnnotationMode`.
81
84
82
85
{% tabs %}
83
-
{% highlight js tabtitle="Standalone" %}
84
-
{% raw %}
85
-
import * as React from 'react';
86
-
import * as ReactDOM from 'react-dom/client';
87
-
import { PdfViewerComponent, Inject, Toolbar, Annotation, TextSelection } from '@syncfusion/ej2-react-pdfviewer';
88
-
import { ToolbarComponent, ItemsDirective, ItemDirective } from '@syncfusion/ej2-react-navigations';
89
-
90
-
function getViewer() { return document.getElementById('container').ej2_instances[0]; }
91
-
92
-
function onToolbarClick(args) {
93
-
const modeMap = {
86
+
{% highlight ts tabtitle="Standalone" %}
87
+
import { Component } from '@angular/core';
88
+
import { PdfViewerModule, ToolbarService, AnnotationService, TextSelectionService } from '@syncfusion/ej2-angular-pdfviewer';
89
+
import { ToolbarModule, ClickEventArgs } from '@syncfusion/ej2-angular-navigations';
0 commit comments