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

How to set hilight for matched words from search

More
IP: 192.168.0.70 12 years 1 month ago - 12 years 1 month ago #5106 by Sanguanchai
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: 12 years 1 month ago by kadrimanaj.
More
IP: 192.168.0.158 12 years 1 month ago #5110 by nermeen
That's because the PDFGotoPage takes sometime to do the render, try the following:
Code:
PDFReader.PDFGotoPage(pageNumber); new Handler().postDelayed(new Runnable() { public void run() { txt_find.setText(keyword); onFindNext(); } }, 10);
More
IP: 192.168.0.70 12 years 1 month ago - 12 years 1 month ago #5118 by Sanguanchai
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: 12 years 1 month ago by kadrimanaj.
More
IP: 192.168.0.158 12 years 1 month ago #5119 by nermeen
Already tested before posting, try to increase the delay (use 100 for example)
More
IP: 192.168.0.70 12 years 1 month ago #5127 by Sanguanchai
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.
More
IP: 192.168.0.158 12 years 1 month ago #5135 by nermeen
Here, check PDFReaderAct.InitView()


File Attachment:

File Name: PDFReaderAct.java
File Size:21.38 KB
Time to create page: 0.394 seconds
Powered by Kunena Forum