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

TOPIC:

How to set hilight for matched words from search 7 years 7 months ago #5106

  • Sanguanchai
  • Sanguanchai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
I tried to use "PDFView.FindStart" and "PDFView.Find" after it finish to render pdf viewer. But it hi-light matched word from wrong page. For example, if I navigate to page 9 and set keyword to "the", it will hil-light "the" in the page 8. Please see the example code below.

Example Code
PDFReader.PDFGotoPage(pageNumber);
txt_find.setText(keyword);
onFindNext();

private void onFindNext()
{
String str = txt_find.getText().toString();
if( str_find != null )
{
if( str != null && str.compareTo(str_find) == 0 )
{
m_reader.PDFFind(1);
return;
}
}
if( str != null && str.length() > 0 )
{
m_reader.PDFFindStart(str, false, false);
m_reader.PDFFind(1);
str_find = str;
}
}

Could you please suggest me how I fix this problem?

Thanks,
Sanguanchai
Last edit: by kadrimanaj.
The topic has been locked.

How to set hilight for matched words from search 7 years 7 months ago #5110

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
That's because the PDFGotoPage takes sometime to do the render, try the following:
PDFReader.PDFGotoPage(pageNumber);
new Handler().postDelayed(new Runnable() {			
	public void run() {
		txt_find.setText(keyword);
		onFindNext();
	}
}, 10);
The topic has been locked.

How to set hilight for matched words from search 7 years 7 months ago #5118

  • Sanguanchai
  • Sanguanchai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
I tried by using your code, it does not work. It still search from wrong page. Could you please try to test it by add this code in the file "PDFReaderAct.java"?

Thanks,
Sanguanchai
Last edit: by kadrimanaj.
The topic has been locked.

How to set hilight for matched words from search 7 years 7 months ago #5119

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
Already tested before posting, try to increase the delay (use 100 for example)
The topic has been locked.

How to set hilight for matched words from search 7 years 7 months ago #5127

  • Sanguanchai
  • Sanguanchai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
Could you provide "PDFReaderAct.java" that you have already modified code to navigate to page and search? I tried to increase delay to 1000 and it does not work.
The topic has been locked.

How to set hilight for matched words from search 7 years 7 months ago #5135

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
Here, check PDFReaderAct.InitView()


File Attachment:

File Name: PDFReaderAct.java
File Size:21 KB
Attachments:
The topic has been locked.
Powered by Kunena Forum