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

Adding Annotations Not Functioning

More
IP: 192.168.0.71 11 years 5 months ago - 11 years 5 months ago #7613 by abhishekjaju
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: 11 years 5 months ago by Nygashi.
More
IP: 192.168.0.71 11 years 5 months ago #7619 by radaee
mFinder.GetCount(); may return 0
in this case, no found results.
More
IP: 192.168.0.71 11 years 5 months ago - 11 years 5 months ago #7621 by abhishekjaju
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: 11 years 5 months ago by Nygashi.
More
IP: 192.168.0.71 11 years 5 months ago #7622 by radaee
to get all found results,
you need a loop:
int fcount = mFinder.GetCount();
for( int ifind = 0; ifind < fcount; ifind++ )
{
//...
}
More
IP: 192.168.0.71 11 years 5 months ago #7630 by abhishekjaju
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.
More
IP: 192.168.0.158 11 years 5 months ago #7650 by nermeen
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.
Code:
... 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); } ...
Time to create page: 0.422 seconds
Powered by Kunena Forum