Customizing default annotation styles
An annotation's default style is the style it is created with when created through its associated tool. For example, a freetext annotation create tool may set the stroke color, stroke thickness, fill color, text color, font size and/or opacity of the annotation shortly after creation, which becomes their 'default' or initial style.
Changing the default annotation style
To change the default style, you can use the setStyles API on the tool objects.
WebViewer({ ... }, viewerElement)
.then(instance => {
const { documentViewer, Annotations } = instance.Core;
documentViewer.getTool('AnnotationCreateTextHighlight').setStyles({
StrokeColor: new Annotations.Color(0, 221, 255)
});
documentViewer.getTool('AnnotationCreateFreeText').setStyles({
StrokeThickness: 5,
StrokeColor: new Annotations.Color(0, 0, 255),
TextColor: new Annotations.Color(0, 0, 0),
FontSize: '20pt'
});
});WebViewer({ ... }, viewerElement)
.then(instance => {
const { docViewer, Annotations } = instance;
docViewer.getTool('AnnotationCreateTextHighlight').setStyles(currentStyle => ({
StrokeColor: new Annotations.Color(0, 221, 255)
}));
docViewer.getTool('AnnotationCreateFreeText').setStyles(currentStyle => ({
StrokeThickness: 5,
StrokeColor: new Annotations.Color(0, 0, 255),
TextColor: new Annotations.Color(0, 0, 0),
FontSize: '20pt'
}));
});Using the defaults object
On the annotation create tools, you will find a defaults object that contains the values used to initialize the annotation style properties. If you need to read the initial values, you can use this object.
Next steps
If you want to check out which properties are available on the annotations themselves, check out the annotation type guides.
Last updated
Was this helpful?