Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

ObjsGetCharIndex only works at first time

More
IP: 192.168.0.71 11 years 9 months ago #6457 by discoby
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();
More
IP: 192.168.0.71 11 years 9 months ago #6458 by discoby
Now i can get other hit word every time, if i avoid doing page.close()...

But in some articles' reply, page.close() is necessary to avoid momory leak....

What is the correct procedure?????
More
IP: 192.168.0.71 11 years 9 months ago #6459 by radaee
Page object obtained by PDFVPage object is managed by PDFView class.
you shall not close the Page object from PDFVPage.
Time to create page: 0.398 seconds
Powered by Kunena Forum