Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

Char index 8 years 9 months ago #9205

  • Gracanin
  • Gracanin's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
Hi,
I'm trying to calculate first and last character index after selecting text in PDF. In OnPDFSelecting method I'm trying to calculate it by using page.ObjsGetCharIndex(new float[]{rects1[0], rects1[1]}), however result is always -1. Do you have any suggestion how to properly calculate first and last char index?

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

Char index 8 years 9 months ago #9213

  • Gracanin
  • Gracanin's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
Still trying to figure out solution for this. Any help?

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

Char index 8 years 9 months ago #9221

  • support
  • support's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 692
  • Thank you received: 59
It's not clear what the index you're looking for is.
The index of the selected string?
The index in the whole page?
Something different?

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

Char index 8 years 9 months ago #9222

  • Gracanin
  • Gracanin's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 25
  • Thank you received: 0
I'm looking for the first and last index of the selected string on certain page. For example, assume this is the only text on page:

"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim."

I want to find out first and last index of bolded text (consectetuer adipiscing) - in this case first index is around 30, last around 50.

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

Last edit: by Gracanin.

Char index 8 years 9 months ago #9225

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
page.ObjsGetCharIndex(new float[]{rects1[0], rects1[1]}), returns always -1 because before this method you have to call:
page.ObjsStart();
to get text objects to memory.
For more info check this
Remember that the index you get with this method depends on the pdf structure.

I suggest you to check
int count = page.ObjsGetCharCount();
String pageText = page.ObjsGetString(0, count - 1);
to get the text of the whole page.

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

  • Page:
  • 1
Powered by Kunena Forum