AnnotationManager
Annotation Types
Customize
Annotations take up a certain amount of space on a document page. Their "body" in the document is commonly represented as a rectangle or an array of rectangles. These rectangles are provided as either a Rect or Quad object in WebViewer.
Most annotations will use a Rect as their body, whereas Quad objects are typically for annotations that mark up text. With a Quad, you can convert it to a Rect and vice-versa. With a Rect, you can get more information from the shape such as its dimensions or checking for intersections with other rectangles.
Most annotations will work with Rect objects. Specifically for resizing through the use of setRect.
There are two APIs for collision detection. You can use either intersect or contains with another rectangle to check if the two rectangle bodies overlap. The difference, however, is that contains strictly checks whether one rectangle is inside another.
Occasionally, you may need to transform a rectangle a certain way or perhaps you need a special transformation for your custom annotation. In this case, you can transform a Rect with a Matrix.
However, matrices are difficult to work with and are not easily recognizable. WebViewer provides a TransformationBuilder to assist in building a transformation out. The operations you set with the TransformationBuilder is in the order you would perform them (not in reverse order).
If you want to use the transformation matrix with the Canvas context, you can use the toTransform API on the Matrix to get an array of values to be used with setTransform on the context.
Quads are commonly found with annotations that mark up text. In many of the cases, these annotations, like HighlightAnnotation, contain a list of Quad objects representing the lines of text that are marked.
RectQuad objects are limited in functionality, but you can convert them to a Rect where you will gain access to its APIs. After you are done, you can convert it back to a Quad.
To convert it back:
See how Rect and Quad objects are used in some of our annotation guides, specifically RectangleAnnotation and HighlightAnnotation!
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales