VintaSoft Imaging .NET SDK 15.1: Documentation for Web developer
In This Topic
How to draw text on web rectangle annotation?
In This Topic
By default only 4 web annotations (WebTextAnnotationViewJS, WebStampAnnotationViewJS, WebStickyNoteAnnotationViewJS, WebFreeTextAnnotationViewJS) display text.
Other web annotations also can display text if annotation is derived from WebTextAnnotationViewBaseJS class.
For example, web annotations WebRectangleAnnotationViewJS, WebEllipseAnnotationViewJS, WebLinesAnnotationViewJS, WebPolygonAnnotationViewJS are derived from WebTextAnnotationViewBaseJS class and can display text.

If you need to display text in WebRectangleAnnotationViewJS, WebEllipseAnnotationViewJS, WebLinesAnnotationViewJS, WebPolygonAnnotationViewJS, just get an instance of WebAnnotationTextPropertiesJS class using WebTextAnnotationViewBaseJS.get_TextProperties function and change text properties (text, text align, text transparency, auto size, font, font brush, auto font size).

If you need to edit the annotation text using text box in web annotation viewer, enable the text box transformer using the WebTextAnnotationViewBaseJS.set_IsTextBoxTransformerEnabled function.

Here is JavaScript code that shows how to display text on rectangle annotation in web annotation viewer:
// create web rectangle annotation
var rectAnno = new WebRedactionAnnotationViewJS();
// set the annotation location
rectAnno.set_Location(318, 264);
// set the annotation size
rectAnno.set_Size(250, 200);
// set the annotation text
rectAnno.get_TextProperties().set_Text("Text on rect");

// get annotation visual tool from annotation viewer
_annotationVisualTool = annotationViewer1.get_AnnotationVisualTool();
// add created annotation to the focused image
_annotationVisualTool._focusedCollection.add(redactionAnno);