Skip to content

Commit 319f65b

Browse files
996394: Updated UG Documentation for Annotation Revamp
1 parent 0568664 commit 319f65b

9 files changed

Lines changed: 1044 additions & 0 deletions

File tree

42.5 KB
Loading
33.6 KB
Loading
44.7 KB
Loading
43.5 KB
Loading
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
---
2+
layout: post
3+
title: Radius annotation in TypeScript PDF Viewer | Syncfusion
4+
description: Learn to add, edit, and customize Radius measurement annotations in Syncfusion TypeScript PDF Viewer with UI and programmatic examples.
5+
platform: document-processing
6+
control: PDF Viewer
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Radius annotation in TypeScript PDF Viewer
12+
13+
Radius is a measurement annotation used to measure the radius of a circle in the PDF.
14+
15+
![Radius annotations overview](../annotation-images/radius-annot.png)
16+
17+
## Add Radius Annotation
18+
19+
### Add radius annotation via UI
20+
21+
Use the annotation toolbar:
22+
- Click the Edit Annotation button in the PDF Viewer toolbar.
23+
- Open the Measurement Annotation dropdown.
24+
- Choose Radius, then draw on the page.
25+
26+
N> When in pan mode, selecting a measurement annotation switches the viewer to text select mode.
27+
28+
![Measurement toolbar](../../images/calibrate_tool.png)
29+
30+
### Add a radius annotation programmatically
31+
32+
#### Enable radius mode
33+
34+
The PDF Viewer component allows drawing Radius annotations programmatically after enabling Radius mode in button clicks.
35+
36+
```html
37+
<button id="radiusMode">Radius</button>
38+
```
39+
40+
{% tabs %}
41+
{% highlight ts tabtitle="Standalone" %}
42+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
43+
44+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
45+
46+
let pdfviewer: PdfViewer = new PdfViewer();
47+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
48+
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
49+
pdfviewer.appendTo('#PdfViewer');
50+
51+
document.getElementById('radiusMode')?.addEventListener('click', () => {
52+
pdfviewer.annotationModule.setAnnotationMode('Radius');
53+
});
54+
{% endhighlight %}
55+
{% highlight ts tabtitle="Server-Backed" %}
56+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
57+
58+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
59+
60+
let pdfviewer: PdfViewer = new PdfViewer();
61+
pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
62+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
63+
pdfviewer.appendTo('#PdfViewer');
64+
65+
document.getElementById('radiusMode')?.addEventListener('click', () => {
66+
pdfviewer.annotationModule.setAnnotationMode('Radius');
67+
});
68+
{% endhighlight %}
69+
{% endtabs %}
70+
71+
#### Exit radius mode
72+
73+
```html
74+
<button id="setNone">Normal Mode</button>
75+
```
76+
77+
{% tabs %}
78+
{% highlight ts tabtitle="Common" %}
79+
document.getElementById('setNone')?.addEventListener('click', () => {
80+
pdfviewer.annotationModule.setAnnotationMode('None');
81+
});
82+
{% endhighlight %}
83+
{% endtabs %}
84+
85+
#### Add radius annotation
86+
87+
Add measurement annotations programmatically using the [addAnnotation()](https://ej2.syncfusion.com/documentation/api/pdfviewer/annotation#annotation) method.
88+
89+
```html
90+
<button id="addRadiusAnnotation">Add Radius annotation programmatically</button>
91+
```
92+
93+
{% tabs %}
94+
{% highlight ts tabtitle="Standalone" %}
95+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, RadiusSettings } from '@syncfusion/ej2-pdfviewer';
96+
97+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
98+
99+
let pdfviewer: PdfViewer = new PdfViewer();
100+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
101+
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
102+
pdfviewer.appendTo('#PdfViewer');
103+
104+
document.getElementById('addRadiusAnnotation')?.addEventListener('click', () => {
105+
pdfviewer.annotation.addAnnotation('Radius', {
106+
offset: { x: 200, y: 630 },
107+
pageNumber: 1,
108+
width: 90,
109+
height: 90
110+
} as RadiusSettings);
111+
});
112+
{% endhighlight %}
113+
{% highlight ts tabtitle="Server-Backed" %}
114+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer, RadiusSettings } from '@syncfusion/ej2-pdfviewer';
115+
116+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
117+
118+
let pdfviewer: PdfViewer = new PdfViewer();
119+
pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
120+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
121+
pdfviewer.appendTo('#PdfViewer');
122+
123+
document.getElementById('addRadiusAnnotation')?.addEventListener('click', () => {
124+
pdfviewer.annotation.addAnnotation('Radius', {
125+
offset: { x: 200, y: 630 },
126+
pageNumber: 1,
127+
width: 90,
128+
height: 90
129+
} as RadiusSettings);
130+
});
131+
{% endhighlight %}
132+
{% endtabs %}
133+
134+
## Edit Radius Annotation
135+
136+
### Edit radius annotation in UI
137+
138+
You can select, move, and resize Radius annotations directly in the viewer:
139+
- Select a Radius measurement to show its handles.
140+
- Move: drag the shape to reposition it on the page.
141+
- Resize: drag the handles to adjust its size.
142+
- Delete or access more options from the context menu.
143+
144+
### Edit the properties of radius annotations
145+
146+
The fill color, stroke color, thickness, and opacity can be edited using the Edit Color, Edit Stroke Color, Edit Thickness, and Edit Opacity tools in the annotation toolbar.
147+
148+
#### Edit fill color
149+
150+
The fill color of the annotation can be edited using the color palette provided in the Edit Color tool.
151+
152+
![CalibrateFillColor](../../images/calibrate_fillcolor.png)
153+
154+
#### Edit stroke color
155+
156+
The stroke color of the annotation can be edited using the color palette provided in the Edit Stroke Color tool.
157+
158+
![CalibrateStrokeColor](../../images/calibrate_stroke.png)
159+
160+
#### Edit thickness
161+
162+
Edit border thickness using the range slider provided in the Edit Thickness tool.
163+
164+
![CalibrateThickness](../../images/calibrate_thickness.png)
165+
166+
#### Edit opacity
167+
168+
The opacity of the annotation can be edited using the range slider provided in the Edit Opacity tool.
169+
170+
![CalibrateOpacity](../../images/calibrate_opacity.png)
171+
172+
### Edit an existing radius annotation programmatically
173+
174+
Use editAnnotation on items from annotationCollection.
175+
176+
```html
177+
<button id="editRadiusAnnotation">Edit Radius annotation programmatically</button>
178+
```
179+
180+
{% tabs %}
181+
{% highlight ts tabtitle="Standalone" %}
182+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
183+
184+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
185+
186+
let pdfviewer: PdfViewer = new PdfViewer();
187+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
188+
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
189+
pdfviewer.appendTo('#PdfViewer');
190+
191+
document.getElementById('editRadiusAnnotation')?.addEventListener('click', () => {
192+
for (let i = 0; i < pdfviewer.annotationCollection.length; i++) {
193+
if (pdfviewer.annotationCollection[i].subject === 'Radius calculation') {
194+
pdfviewer.annotationCollection[i].strokeColor = '#0000FF';
195+
pdfviewer.annotationCollection[i].thickness = 2;
196+
pdfviewer.annotationCollection[i].opacity = 0.8;
197+
pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]);
198+
}
199+
}
200+
});
201+
{% endhighlight %}
202+
{% highlight ts tabtitle="Server-Backed" %}
203+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
204+
205+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
206+
207+
let pdfviewer: PdfViewer = new PdfViewer();
208+
pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
209+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
210+
pdfviewer.appendTo('#PdfViewer');
211+
212+
document.getElementById('editRadiusAnnotation')?.addEventListener('click', () => {
213+
for (let i = 0; i < pdfviewer.annotationCollection.length; i++) {
214+
if (pdfviewer.annotationCollection[i].subject === 'Radius calculation') {
215+
pdfviewer.annotationCollection[i].strokeColor = '#0000FF';
216+
pdfviewer.annotationCollection[i].thickness = 2;
217+
pdfviewer.annotationCollection[i].opacity = 0.8;
218+
pdfviewer.annotation.editAnnotation(pdfviewer.annotationCollection[i]);
219+
}
220+
}
221+
});
222+
{% endhighlight %}
223+
{% endtabs %}
224+
225+
## Default radius settings during initialization
226+
227+
Set default [radiusSettings](https://ej2.syncfusion.com/documentation/api/pdfviewer/index-default#radiussettings) before creating the control.
228+
229+
{% tabs %}
230+
{% highlight ts tabtitle="Standalone" %}
231+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
232+
233+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
234+
235+
let pdfviewer: PdfViewer = new PdfViewer();
236+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
237+
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
238+
pdfviewer.radiusSettings = { fillColor: 'orange', opacity: 0.6, strokeColor: 'pink' };
239+
pdfviewer.appendTo('#PdfViewer');
240+
{% endhighlight %}
241+
{% highlight ts tabtitle="Server-Backed" %}
242+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
243+
244+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
245+
246+
let pdfviewer: PdfViewer = new PdfViewer();
247+
pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
248+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
249+
pdfviewer.radiusSettings = { fillColor: 'orange', opacity: 0.6, strokeColor: 'pink' };
250+
pdfviewer.appendTo('#PdfViewer');
251+
{% endhighlight %}
252+
{% endtabs %}
253+
254+
## Scale ratio and units
255+
256+
You can modify scale ratio and units using the Scale Ratio option in the context menu.
257+
258+
![Scale ratio](../../images/calibrate_scaleratio.png)
259+
260+
Supported units:
261+
- Inch, Millimeter, Centimeter, Point, Pica, Feet
262+
263+
![Scale dialog](../../images/calibrate_scaledialog.png)
264+
265+
Set defaults via measurementSettings:
266+
267+
{% tabs %}
268+
{% highlight ts tabtitle="Standalone" %}
269+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
270+
271+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
272+
273+
let pdfviewer: PdfViewer = new PdfViewer();
274+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
275+
pdfviewer.resourceUrl = "https://cdn.syncfusion.com/ej2/31.1.23/dist/ej2-pdfviewer-lib";
276+
pdfviewer.measurementSettings = { scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm' };
277+
pdfviewer.appendTo('#PdfViewer');
278+
{% endhighlight %}
279+
{% highlight ts tabtitle="Server-Backed" %}
280+
import { PdfViewer, Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer } from '@syncfusion/ej2-pdfviewer';
281+
282+
PdfViewer.Inject(Toolbar, Magnification, Navigation, Annotation, LinkAnnotation, ThumbnailView, BookmarkView, TextSelection, TextSearch, FormFields, FormDesigner, PageOrganizer);
283+
284+
let pdfviewer: PdfViewer = new PdfViewer();
285+
pdfviewer.serviceUrl = 'https://document.syncfusion.com/web-services/pdf-viewer/api/pdfviewer/';
286+
pdfviewer.documentPath = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
287+
pdfviewer.measurementSettings = { scaleRatio: 2, conversionUnit: 'cm', displayUnit: 'cm' };
288+
pdfviewer.appendTo('#PdfViewer');
289+
{% endhighlight %}
290+
{% endtabs %}
291+
292+
[View Sample on GitHub](https://github.com/SyncfusionExamples/typescript-pdf-viewer-examples/tree/master)

0 commit comments

Comments
 (0)