Get the points of erased annotation

Hello,

I am trying to save shape coords in db and send them to server and redraw it again from db. Its working great but the only problem is in erase! Whatever points I am getting from erase is not matching with shape stored in db.

Below is the code snippet for erase inside Erase.java where I am trying retrieve x,y cords of annotation that is being deleted.

// Erase
double[] pt1points = mPDFView.convScreenPtToPagePt(mPrevPt.x, mPrevPt.y, mDownPageNum);
double[] pt2points = mPDFView.convScreenPtToPagePt(mCurrentPt.x, mCurrentPt.y, mDownPageNum);
Point pdfPt1 = new Point(pt1points[0], pt1points[1]);
Point pdfPt2 = new Point(pt2points[0], pt2points[1]);

try {
mPDFView.docLock(true);
Page page = mPDFView.getDoc().getPage(mDownPageNum);
int annot_num = page.getNumAnnots();
int count=0;
for (int i=annot_num-1;i>=0;–i) {
Annot annot = page.getAnnot(i);
if (!annot.isValid())
continue;
if (annot.getType() == Annot.e_Ink) {
Ink ink = new Ink(annot);
Point point =ink.GetPoint(0, count); //Getting points of annotation I think I am messing here!
if (ink.erase(pdfPt1, pdfPt2, mEraserHalfThickness)) {
ErasedPoints erased=new ErasedPoints();
erased.setxCoord(point.x);
erased.setyCoord(point.y);
erasedPoints.add(erased);
Log.i(“Erased”, "Erased GetPoint at “+count+” “+point.x+” "+point.y );
Log.i(“Erased”, "Erased onMove “+pdfPt1.x+” “+pdfPt1.y+” “+pdfPt2.x+” "+pdfPt2.y);
if (!mInkList.contains(ink)) {
mInkList.add(ink);
mDoUpdate = true;
}
}

}
count++;

}
Log.i("Loop count ","Loop count "+count);
} catch (Exception ex) {

} finally {
mPDFView.docUnlock();
mPrevPt.x = mCurrentPt.x;
mPrevPt.y = mCurrentPt.y;
}

First you are passing in the mouse coordinates (pdfPt[1|2]), which of course doesn’t match the ink points.

Also, when erasing, PDFNet might create/modify/delete other surrounding points can. For instance when erasing the midpoint between two Ink points.

What you should do is reload the entire Ink list from the Annotation after erasing, and replace what is in your database. This will save you a lot of headaches, and will protect you from possible future implementation changes in our library.

Note, PDF Annotations can have a Unique (Document wide) Id associated with them.

https://www.pdftron.com/pdfnet/docs/PDFNet/?topic=html/M_pdftron_PDF_Annot_SetUniqueID.htm

https://www.pdftron.com/pdfnet/docs/PDFNet/?topic=html/M_pdftron_PDF_Annot_GetUniqueID.htm