How to create a FreeHand (Ink) Eraser Tool

Q: I am using iOS and would like to create an eraser tool for freehand annotations. How can I do this?

A:

PDFViewCtrl includes the selector GetAnnotationAt:y: that allows you
to quickly determine if there is an annotation present where the user
has touched. You could use it to help implement an eraser tool that
erases any annotation that the user touches or moves their finger
over.

Specifically for free hand annotations, they consist of a set of set of points, where each set of points is a continuous line. To erase part of a line, you would need to calculate if the location of a touch intersected the line between two points. If it does, that line segment would need to be broken into to line segments, and their endpoints adjusted so that the spot touched by the user is no longer part of either line segment. If you look at the file FreeHandCreate.m, you will see in the onTouchesEnded:withEvent: selector where a freehand annotation is created. You will need to mimic some of this functionality when breaking a line segment into two. For an existing annotation, you can determine the line segments and their points using the Ink annotation API. This erasing functionality is something that we would like to implement, and while it is not in our short term plans to do so, we are here to help answer any questions you might have while implementing it on your side.