- Posts: 36
- Thank you received: 0
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
Find and Highlight only current page (Standard License)
- thiagopelikan
- Topic Author
- Offline
- Junior Member
-
Less
More
IP: 201.82.35.205
5 years 2 months ago - 5 years 2 months ago #15391
by thiagopelikan
Hi, I need to find some texts only in my current page. I tried two things.
1) Using "FIND" feature.
When I use PDFFind, it search for the whole document and highlight all occurences. What can I do to use "PDFFind" only in a especied page?
2) As an alternative, I tried to use the code below to find only in the current page, the word is found, but now I don't know how to highlight it. I'm using standard license so it's not possible to use the feature "annotation".
Page currentPage = document.GetPage(current);
currentPage.ObjsStart();
Page.Finder mFinder = currentPage.FindOpen("MYTEXT", false, false);
if (mFinder != null) {
int finds = mFinder.GetCount();
System.err.println("page " + (current + 1) + " " + finds);
mFinder.Close();
currentPage.Close();
}
1) Using "FIND" feature.
When I use PDFFind, it search for the whole document and highlight all occurences. What can I do to use "PDFFind" only in a especied page?
2) As an alternative, I tried to use the code below to find only in the current page, the word is found, but now I don't know how to highlight it. I'm using standard license so it's not possible to use the feature "annotation".
Page currentPage = document.GetPage(current);
currentPage.ObjsStart();
Page.Finder mFinder = currentPage.FindOpen("MYTEXT", false, false);
if (mFinder != null) {
int finds = mFinder.GetCount();
System.err.println("page " + (current + 1) + " " + finds);
mFinder.Close();
currentPage.Close();
}
Last edit: 5 years 2 months ago by thiagopelikan.
IP: 111.196.247.170
5 years 2 months ago - 5 years 2 months ago #15393
by radaee
Replied by radaee on topic Find and Highlight only current page (Standard License)
dear user, draw selected text is implemented in class:
com.radaee.view.VSel
this class is invoked by PDFLayoutView class.
the key points is:
1. selected rectangle is merged from rectangle of each chars, char rect can be obtained from Page.ObjsGetCharRect() by char index.
2. scale and offset the merged rectangles, and keep same to rendering scale and offset.
3. draw scaled rectangles over rendering result, maybe on another layer, maybe on canvas from bitmap object.
com.radaee.view.VSel
this class is invoked by PDFLayoutView class.
the key points is:
1. selected rectangle is merged from rectangle of each chars, char rect can be obtained from Page.ObjsGetCharRect() by char index.
2. scale and offset the merged rectangles, and keep same to rendering scale and offset.
3. draw scaled rectangles over rendering result, maybe on another layer, maybe on canvas from bitmap object.
Last edit: 5 years 2 months ago by radaee.
- thiagopelikan
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 36
- Thank you received: 0
IP: 201.82.35.205
5 years 2 months ago #15394
by thiagopelikan
Replied by thiagopelikan on topic Find and Highlight only current page (Standard License)
Hi, I tried the following:
int foundIndex = mFinder.GetFirstChar(0); //get the index of first occurence
float rect[] = new float[4];
currentPage.ObjsGetCharRect(foundIndex, rect);
But rect value is wrong. What I'm missing? Tks!
int foundIndex = mFinder.GetFirstChar(0); //get the index of first occurence
float rect[] = new float[4];
currentPage.ObjsGetCharRect(foundIndex, rect);
But rect value is wrong. What I'm missing? Tks!
IP: 111.196.247.170
5 years 2 months ago #15395
by radaee
Replied by radaee on topic Find and Highlight only current page (Standard License)
no, the rect shall be correct.
but coordinate system of char rect is not screen coordinate system.
please read method VSel.DrawSel() carefully:
the y coordinate value is inverted as screen coordinate value.
but coordinate system of char rect is not screen coordinate system.
please read method VSel.DrawSel() carefully:
Code:
rect_draw[0] = rect_word[0] * scale;
rect_draw[1] = (page_height - rect_word[3]) * scale;
rect_draw[2] = rect_word[2] * scale;
rect_draw[3] = (page_height - rect_word[1]) * scale;
Time to create page: 0.427 seconds