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

TOPIC:

Adding Annotations Not Functioning 9 years 5 months ago #7613

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

Adding Annotations Not Functioning 9 years 5 months ago #7619

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

Adding Annotations Not Functioning 9 years 5 months ago #7621

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

Adding Annotations Not Functioning 9 years 5 months ago #7622

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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 9 years 5 months ago #7630

  • abhishekjaju
  • abhishekjaju's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 40
  • Thank you received: 1
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 9 years 5 months ago #7650

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
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.
  • Page:
  • 1
Powered by Kunena Forum