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 10 years 2 months ago #5084

  • Sanguanchai
  • Sanguanchai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
I am evaluating your Android PDF Viewer Library to show pdf viewer embedded in the app and need to search functionality. User can search by using keyword and it will show all matched result for all pages in the pdf file. (display all matched result in "ListView") When user clicks the matched result in the row of ListView, it will go to pdf viewer and hilight matched word in the page.

for (int i = 0; i < doc.GetPageCount(); i++)
{
Page page = doc.GetPage(i);
page.ObjsStart();
Finder finder = page.FindOpen(keyword, false, false);
int numMatch = finder.GetCount();

if (numMatch > 0)
{
for (int j = 0; j < numMatch; j++)
{
int startIndex = finder.GetFirstChar(j);
float[] vals = new float[4];
page.ObjsGetCharRect(startIndex, vals);
//I tried to use PDFView.vSetSel() by using the code, but it hilightly position for matched word.
//PDFView.vSetSel(vals[0], vals[1], vals[2], vals[3])

}
}
}

The problem is how do I set hilight color for matched word in the pdf viewer? I tried to use the function "PDFView.vSetSel()" but it does not work. It hilight incorrectly position for matched word. I cannot use "PDFReader.PDFFind" because there may have many matched result in the same page. (For example, I search by using keyword "the", there are 10 matched result in the page 1.)

Could you please provide the example of code that I can use to set hilight color for matched word in the pdf viewer? I cannot find more information from API document and tried to review code from "PDFReaderAct.java" and "PDFReader.java" for 2 - 3 days but I still don't know how to set hilight color for matched word in the pdf viewer.

Thanks for helping
Last edit: by kadrimanaj.
The topic has been locked.

How to set hilight for matched words from search 10 years 2 months ago #5094

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
The topic has been locked.

How to set hilight for matched words from search 10 years 2 months ago #5096

  • Sanguanchai
  • Sanguanchai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
Sorry, I don't want to show all matched words for the page, I just want to show selected matched word for the page. For example, if I searched by using keyword "the", the search result will be 2 rows like this.
1. The xxx (for match#1 in page#1)
2. The yyy (for match#2 in page#1)

If user clicks "The yyy", it should hilight selected "The yyy" in the pdf viewer instead of hilight both "The xxx" and "The yyy".

For your suggestion, I am not sure which class that we will implement for "vDraw"? If you means "PDFView.vDraw", we cannot do this because we have only "jar" file for "com.radaee.pdfex_view.jar". We don't have source files for this jar. Can you please provide link to download source files for this jar?
Last edit: by kadrimanaj.
The topic has been locked.

How to set hilight for matched words from search 10 years 2 months ago #5097

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
In this case you need to change the behavior of the find..
You need to change in PDFView.vDraw and PDFVFinder.find_draw..

To modify these classes you need the source of the jar file, (for professional and premium license) which can be downloaded from www.androidpdf.mobi/shop/key-request after entering Order reference and PIN, click Order status then you can find a drop list where you can choose the appropriate version and download
The topic has been locked.

How to set hilight for matched words from search 10 years 2 months ago #5098

  • Sanguanchai
  • Sanguanchai's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 8
  • Thank you received: 0
Can we use "PDFView.vSetSel()" or other methods to set hi-light color for matched word? I try to use this method ("PDFView.vSetSel(rects[0], rects[1], rects[2], rects[3])" by pass "float[4] rects" from "page.ObjsGetCharRect(startIndex, rects)" but it hi-light incorrectly? Do you have any suggestion?
The topic has been locked.

How to set hilight for matched words from search 10 years 2 months ago #5099

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
First this methods is usually used to for highlight annotation.

Second, note that the method ObjsGetCharRect returns (one char's box in PDF coordinate system)
and the method vSetSel calculates the PDF corrdinates for the passed parameters..that's why the result is not right..


The better solution is to use PDFVFinder or you need to implement your own method
The topic has been locked.
Powered by Kunena Forum