RadaeePDF.com :: Topic: Adding Annotations Not Functioning (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF

TOPIC: Adding Annotations Not Functioning

Adding Annotations Not Functioning 2 years 8 months ago #7613

  • abhishekjaju
  • abhishekjaju's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1
  • Karma: 0
When I am searching "Android" text in whole PDF I am not able to add annotations correctly.
It will only search for the first "Android" text on every page of the whole pdf.
I want to addURI to all "Android" Word in the complete PDF.
So please give example to seach all "Android" words in PDF and get cordinates of every particular "Android" text.
I used below code for achiving, but I am not getting desired result.


public void AddAnnonateURI() {
String str = "Android";
int pagesCount = m_doc.GetPageCount();
for (int i = 0; i < pagesCount; i++) {
Page currentPage = m_doc.GetPage(i);
currentPage.ObjsStart();
// Finder mFinder = new Finder();
Finder mFinder = currentPage.FindOpen(str, true, true);
if (mFinder != null) {
int finds = mFinder.GetCount();
int ichar = mFinder.GetFirstChar(0);
int ichar_end = ichar + str.trim().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] }, str);
for (int j = 0; j < finds; j++) {
// System.err.println("page" + (i + 1));
// int foundIndex = mFinder.GetFirstChar(j);
}
mFinder.Close();
}
currentPage.Close();
}
// m_reader.PDFSave();
}
Last Edit: 2 years 8 months ago by Nygashi.
The topic has been locked.

Adding Annotations Not Functioning 2 years 8 months ago #7619

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
mFinder.GetCount(); may return 0
in this case, no found results.
The topic has been locked.

Adding Annotations Not Functioning 2 years 8 months ago #7621

  • abhishekjaju
  • abhishekjaju's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1
  • Karma: 0
I am getting count more than one but not ab;le get co-ordinates of all them.
Only getting co-ordinates of only first match found.
Last Edit: 2 years 8 months ago by Nygashi.
The topic has been locked.

Adding Annotations Not Functioning 2 years 8 months ago #7622

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
to get all found results,
you need a loop:
int fcount = mFinder.GetCount();
for( int ifind = 0; ifind < fcount; ifind++ )
{
//...
}
The topic has been locked.

Adding Annotations Not Functioning 2 years 8 months ago #7630

  • abhishekjaju
  • abhishekjaju's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 40
  • Thank you received: 1
  • Karma: 0
Please see my code..
I have already added the for loop.
The problem is that it will search for the First variable and add uri to it.
Even my loop is for 5 times it will go on to the first word 5 times and add annotations to it.
Please tell me how can we get the Yuri status of a word.. so my loop will skip the word which have already been associated.

Or tell me some other way as the above way is adding ton the first word all the time.
The topic has been locked.

Adding Annotations Not Functioning 2 years 8 months ago #7650

  • nermeen
  • nermeen's Avatar
  • OFFLINE
  • Moderator
  • Posts: 660
  • Thank you received: 38
  • Karma: 17
This means that inside the loop you are always reading the first entry, you need to read the current loop's entry..
and you need to move the part that calculates the coordinates and add the annotation inside the loop.
...
for (int j = 0; j < finds; j++) {
int ichar = mFinder.GetFirstChar(j);
int ichar_end = ichar + str.trim().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] }, str);
}
...
The topic has been locked.
Powered by Kunena Forum