Creating PDF free text annotations using JavaScript

Here is an example of creating a free text annotation using JavaScript, but creating other types of annotations are similar.

1WebViewer(...)
2 .then(instance => {
3 const { Annotations, annotationManager, documentViewer } = instance.Core;
4
5 documentViewer.addEventListener('documentLoaded', () => {
6 const freeText = new Annotations.FreeTextAnnotation();
7 freeText.PageNumber = 1;
8 freeText.X = 150;
9 freeText.Y = 200;
10 freeText.Width = 150;
11 freeText.Height = 50;
12 freeText.setPadding(new Annotations.Rect(0, 0, 0, 0));
13 freeText.setContents('My Text');
14 freeText.FillColor = new Annotations.Color(0, 255, 255);
15 freeText.FontSize = '16pt';
16
17 annotationManager.addAnnotation(freeText, { autoFocus: false });
18 annotationManager.redrawAnnotation(freeText);
19 })
20 })

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales