ObjsGetCharIndex only works at first time - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: ObjsGetCharIndex only works at first time

ObjsGetCharIndex only works at first time 4 years 4 months ago #6457

  • discoby
  • discoby's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
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();

Please Log in or Create an account to join the conversation.

ObjsGetCharIndex only works at first time 4 years 4 months ago #6458

  • discoby
  • discoby's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
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?????

Please Log in or Create an account to join the conversation.

ObjsGetCharIndex only works at first time 4 years 4 months ago #6459

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 846
  • Karma: 43
  • Thank you received: 12
Page object obtained by PDFVPage object is managed by PDFView class.
you shall not close the Page object from PDFVPage.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum