Hello, I am trying to insert Ink annotation on my pdf document, my objective is to insert an annotation relative to the point that has been touched by the user. Currently the code adds the annotion at the bottom left corner of the page. Secondly How can I get the current page number?
private void insertXsymbol(MotionEvent event) {
Page first_page = null;
try {
first_page = doc.getPage(1);
com.pdftron.pdf.annots.Ink ink = com.pdftron.pdf.annots.Ink.create(doc, new Rect(500, 100, 5, 500));
//Point pt3 = new Point(110, 10);
Point pt3 = new Point(event.getX(), event.getY());
//pt3.x = 110; pt3.y = 10;
//ink.setPoint(0, 0, pt3);
pt3.x = 20;
pt3.y = 60;
ink.setPoint(0, 1, pt3);
pt3.x = 30;
pt3.y = 50;
ink.setPoint(0, 2, pt3);
pt3.x = 40;
pt3.y = 40;
ink.setPoint(0, 3, pt3);
pt3.x = 50;
pt3.y = 30;
ink.setPoint(0, 4, pt3);
pt3.x = 60;
pt3.y = 20;
ink.setPoint(0, 4, pt3);
/*-----------------------------------*/
// ink.setPoint(1, 0, pt3);
pt3.x = 20;
pt3.y = 20;
ink.setPoint(1, 1, pt3);
pt3.x = 30;
pt3.y = 30;
ink.setPoint(1, 2, pt3);
pt3.x = 40;
pt3.y = 40;
ink.setPoint(1, 3, pt3);
pt3.x = 50;
pt3.y = 50;
ink.setPoint(1, 4, pt3);
pt3.x = 60;
pt3.y = 60;
ink.setPoint(1, 4, pt3);
/*-----------------------------------*/
/* pt3.x = 200; pt3.y = 100;
ink.setPoint(1, 2, pt3);
pt3.x = 166; pt3.y = 86;
ink.setPoint(2, 0, pt3);
pt3.x = 196; pt3.y = 96;
ink.setPoint(2, 1, pt3);
pt3.x = 221; pt3.y = 121;
ink.setPoint(2, 2, pt3);
pt3.x = 288; pt3.y = 188;
ink.setPoint(2, 3, pt3);*/
ink.setColor(new ColorPt(0, 1, 1), 3);
first_page.annotPushBack(ink);
ink.refreshAppearance();
} catch (PDFNetException e) {
e.printStackTrace();
}
}