How to get coordinates of a searched words - 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
  • 2

TOPIC: How to get coordinates of a searched words

How to get coordinates of a searched words 4 years 2 weeks ago #7568

  • abhishekjaju
  • abhishekjaju's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1
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.
The topic has been locked.

How to get coordinates of a searched words 4 years 2 weeks ago #7574

  • nermeen
  • nermeen's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 865
  • Karma: 23
  • Thank you received: 70
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.
The topic has been locked.

How to get coordinates of a searched words 4 years 2 weeks ago #7581

  • abhishekjaju
  • abhishekjaju's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1
How to get the index of the last character.
The topic has been locked.

How to get coordinates of a searched words 4 years 2 weeks ago #7582

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 846
  • Karma: 43
  • Thank you received: 12
same length to the serch key word, in unicodes.
The topic has been locked.

How to get coordinates of a searched words 4 years 2 weeks ago #7584

  • abhishekjaju
  • abhishekjaju's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1
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.
Last edit: by Nygashi.
The topic has been locked.

How to get coordinates of a searched words 4 years 2 weeks ago #7585

  • nermeen
  • nermeen's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 865
  • Karma: 23
  • Thank you received: 70
this is an example of searching a word and adding annotation to it:
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
}
The topic has been locked.
  • Page:
  • 1
  • 2
Powered by Kunena Forum