How can I use a hatch fill for annotations in WebViewer?

It looks like I made a mistake in the trigger code for 1, I’ve just edited the post, but it should be annotManager.trigger('annotationChanged', [[myAnnotation], 'modify', {}]); note that myAnnotation should be part of an array.

For drawing the hatch fill you can see in the example code that there is a call to ctx.clip which makes sure that the lines are clipped away when drawn outside the shape.

I would expect you would be able to do a similar approach for all types of annotations, clip the shape and then do something similar to those two loops at the bottom of the example code which create the horizontal and vertical lines.

Rectangle will just use the X/Y/Width/Height. Polygon and cloud polygon will draw lines between the path points from annotation.getPath().