- Posts: 25
- Thank you received: 0
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
Char index
10 years 11 months ago #9205
by Gracanin
Char index was created by Gracanin
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?
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?
10 years 11 months ago #9213
by Gracanin
Replied by Gracanin on topic Char index
Still trying to figure out solution for this. Any help?
10 years 11 months ago #9221
by support
Replied by support on topic Char index
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?
The index of the selected string?
The index in the whole page?
Something different?
10 years 11 months ago - 10 years 11 months ago #9222
by Gracanin
Replied by Gracanin on topic Char index
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.
"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.
Last edit: 10 years 11 months ago by Gracanin.
10 years 11 months ago #9225
by Davide
Replied by Davide on topic Char index
Hi,
page.ObjsGetCharIndex(new float[]{rects1[0], rects1[1]}), returns always -1 because before this method you have to call:
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
to get the text of the whole page.
page.ObjsGetCharIndex(new float[]{rects1[0], rects1[1]}), returns always -1 because before this method you have to call:
Code:
page.ObjsStart();
For more info check this
Remember that the index you get with this method depends on the pdf structure.
I suggest you to check
Code:
int count = page.ObjsGetCharCount();
String pageText = page.ObjsGetString(0, count - 1);
Time to create page: 0.452 seconds