- Posts: 40
- Thank you received: 1
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
How to get coordinates of a searched words
- abhishekjaju
- Topic Author
- Offline
- Senior Member
-
Less
More
IP: 192.168.0.71
11 years 3 months ago #7568
by abhishekjaju
How to get coordinates of a searched words was created by abhishekjaju
I am trying hard to get coordinates of a searched word in a PDF page.
For example I have searched a word adobe in a pdf page, now I am not able to get the coordinates of this searched word.
I need to add a annotation to this search word and without getting the coordinates I am not able to add annotation to this searched word.
For example I have searched a word adobe in a pdf page, now I am not able to get the coordinates of this searched word.
I need to add a annotation to this search word and without getting the coordinates I am not able to add annotation to this searched word.
IP: 192.168.0.158
11 years 3 months ago #7574
by nermeen
Replied by nermeen on topic How to get coordinates of a searched words
You can implement it yourself using:
www.androidpdf.mobi/documentation/javado...ml#GetFirstChar(int)
www.androidpdf.mobi/documentation/javado...html#ObjsGetCharRect (int, float[])
The first method will return the index of the first char, you need to pass that index to the second method, and the second method will fill the float[] with the rect of that char...
Then you need to do the same for the last char..and calculate the coordinates of the whole word.
www.androidpdf.mobi/documentation/javado...ml#GetFirstChar(int)
www.androidpdf.mobi/documentation/javado...html#ObjsGetCharRect (int, float[])
The first method will return the index of the first char, you need to pass that index to the second method, and the second method will fill the float[] with the rect of that char...
Then you need to do the same for the last char..and calculate the coordinates of the whole word.
- abhishekjaju
- Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 40
- Thank you received: 1
IP: 192.168.0.71
11 years 3 months ago #7581
by abhishekjaju
Replied by abhishekjaju on topic How to get coordinates of a searched words
How to get the index of the last character.
IP: 192.168.0.71
11 years 3 months ago #7582
by radaee
Replied by radaee on topic How to get coordinates of a searched words
same length to the serch key word, in unicodes.
- abhishekjaju
- Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 40
- Thank you received: 1
IP: 192.168.0.71
11 years 3 months ago - 11 years 3 months ago #7584
by abhishekjaju
Replied by abhishekjaju on topic How to get coordinates of a searched words
Can you please explain with a example.
I am getting a error.
I am getting the Index of first character of the word , then I am adding the searched word length to find index of last character.
But the above method is giving a error.
I am getting a error.
I am getting the Index of first character of the word , then I am adding the searched word length to find index of last character.
But the above method is giving a error.
Last edit: 11 years 3 months ago by Nygashi.
IP: 192.168.0.158
11 years 3 months ago #7585
by nermeen
Replied by nermeen on topic How to get coordinates of a searched words
this is an example of searching a word and adding annotation to it:
Code:
Page currentPage = m_doc.GetPage(page);
currentPage.ObjsStart();
String str = "radaee";
Finder mFinder = currentPage.FindOpen(str, false, false);
if( mFinder != null ) {
int ichar = mFinder.GetFirstChar(0);
int ichar_end = ichar + str.length() - 1;
float rect[] = new float[4];
float rect_end[] = new float[4];
currentPage.ObjsGetCharRect(ichar, rect);
currentPage.ObjsGetCharRect(ichar_end, rect_end);
//currentPage.AddAnnotMarkup(ichar, ichar_end, 0);
currentPage.AddAnnotURI(new float[]{rect[0], rect[1], rect_end[2], rect_end[3]}, "http://www.androidpdf.mobi");
//rerender the page to see the annotation
}
Time to create page: 0.430 seconds