- Posts: 8
- 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
How to set hilight for matched words from search
- Sanguanchai
- Topic Author
- Offline
- New Member
-
Less
More
IP: 192.168.0.70
12 years 1 month ago - 12 years 1 month ago #5106
by Sanguanchai
Replied by Sanguanchai on topic How to set hilight for matched words from search
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
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.
IP: 192.168.0.158
12 years 1 month ago #5110
by nermeen
Replied by nermeen on topic How to set hilight for matched words from search
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);
- Sanguanchai
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
IP: 192.168.0.70
12 years 1 month ago - 12 years 1 month ago #5118
by Sanguanchai
Replied by Sanguanchai on topic How to set hilight for matched words from search
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
Thanks,
Sanguanchai
Last edit: 12 years 1 month ago by kadrimanaj.
IP: 192.168.0.158
12 years 1 month ago #5119
by nermeen
Replied by nermeen on topic How to set hilight for matched words from search
Already tested before posting, try to increase the delay (use 100 for example)
- Sanguanchai
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
IP: 192.168.0.70
12 years 1 month ago #5127
by Sanguanchai
Replied by Sanguanchai on topic How to set hilight for matched words from search
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.
IP: 192.168.0.158
12 years 1 month ago #5135
by nermeen
Replied by nermeen on topic How to set hilight for matched words from search
Here, check PDFReaderAct.InitView()
Time to create page: 0.394 seconds