I want to get the hit word in OnPDFSingleTapped(float x, float y) of demo project.
But i can only get valid char's index at first time, than i just get -1 value after that.
anything i miss?????
Here is the code:
public boolean OnPDFSingleTapped(float x, float y)
{
PDFVPage vpage = m_view.vGetPage(m_pageno);
PDFPos pos = m_view.vGetPos((int)x, (int)y);
float pt[] = new float[2]; pt[0] = pos.x; pt[1] = pos.y;
Page page_cur = vpage.GetPage();
page_cur.ObjsStart();
int idx;
int hit_idx = page_cur.ObjsGetCharIndex(pt);
int hit_srart = hit_idx;
int hit_end = hit_idx;
idx = 1;
while (hit_srart != -1){
idx = page_cur.ObjsAlignWord(hit_srart, -1);
Log.d("###", "idx = " + idx + " hit_srart = " + hit_srart);
if (idx != -1 && idx != hit_srart)
hit_srart = idx;
else
break;
}
idx = 1;
while (hit_end != -1){
idx = page_cur.ObjsAlignWord(hit_end, 1);
Log.d("###", "idx = " + idx + " hit_end = " + hit_end);
if (idx != -1 && idx != hit_end)
hit_end = idx;
else
break;
}
String str = page_cur.ObjsGetString(hit_srart, hit_end+1);
Log.d("###", "str = " + str);
page_cur.Close();