1WebViewer(...)
2.then(instance => {
3 const { annotationManager, Annotations } = instance.Core;
4 const { WidgetFlags } = Annotations;
5
6 // myBtn is your own custom button
7 document.getElementById('myBtn').addEventListener('click', () => {
8
9 // set flags for multiline and required
10 const flags = new WidgetFlags();
11 flags.set('Multiline', true);
12 flags.set('Required', true);
13
14 // create a form field
15 const field = new Annotations.Forms.Field("some text field name", {
16 type: 'Tx',
17 defaultValue: "some placeholder default text value",
18 flags,
19 });
20
21 // create a widget annotation
22 const widgetAnnot = new Annotations.TextWidgetAnnotation(field);
23
24 // set position and size
25 widgetAnnot.PageNumber = 1;
26 widgetAnnot.X = 100;
27 widgetAnnot.Y = 100;
28 widgetAnnot.Width = 50;
29 widgetAnnot.Height = 20;
30
31 //add the form field and widget annotation
32 annotationManager.getFieldManager().addField(field);
33 annotationManager.addAnnotation(widgetAnnot);
34 annotationManager.drawAnnotationsFromList([widgetAnnot]);
35 });
36});