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

TOPIC:

Find and Highlight only current page (Standard License) 3 years 3 months ago #15391

  • thiagopelikan
  • thiagopelikan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 0
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();
}

Please Log in or Create an account to join the conversation.

Last edit: by thiagopelikan.

Find and Highlight only current page (Standard License) 3 years 3 months ago #15393

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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.

Please Log in or Create an account to join the conversation.

Last edit: by radaee.

Find and Highlight only current page (Standard License) 3 years 3 months ago #15394

  • thiagopelikan
  • thiagopelikan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 36
  • Thank you received: 0
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!

Please Log in or Create an account to join the conversation.

Find and Highlight only current page (Standard License) 3 years 3 months ago #15395

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
no, the rect shall be correct.
but coordinate system of char rect is not screen coordinate system.
please read method VSel.DrawSel() carefully:
		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;
the y coordinate value is inverted as screen coordinate value.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum