AndroidPdfViewer icon indicating copy to clipboard operation
AndroidPdfViewer copied to clipboard

Text search in pdf

Open pavelsust opened this issue 7 years ago • 21 comments
trafficstars

Though i like this library very much. But i need a feature like search text in pdf and keyword will be highlighted and go to that page where keyword found.

pavelsust avatar Oct 11 '18 09:10 pavelsust

Hi. I'm new in android. I have used this pdfview library in my app but I want to add search text in the viewer. have you found any way to do it?

erfanfaramarzi avatar Nov 03 '18 07:11 erfanfaramarzi

no still now i don't find this solution. If you found something let me know or if i found something i will comment.

pavelsust avatar Nov 04 '18 11:11 pavelsust

Hello.. Am working on a project where i should contribute with a github repository and solve an issue with it.. so i'll work to add the search feature into the application :)!

Nourhanjx avatar Dec 04 '18 18:12 Nourhanjx

Hi Masud How are you? Unfortunately I couldn't find any solution for searching through PDF android app. I used a PDF viewer but it doesn't have search function. I couldn't understand! Sorry! did you mean you could find a way to search through PDF?

On Tue, Dec 4, 2018 at 9:54 PM Nourhanjx [email protected] wrote:

Hello.. Am working on a project where i should contribute with a github repository and solve an issue with it.. so i'll work to add the search feature into the application :)!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/barteksc/AndroidPdfViewer/issues/697#issuecomment-444204448, or mute the thread https://github.com/notifications/unsubscribe-auth/AqpjLftDykl3bURAi6Os6qi6c4oCKFGHks5u1r3QgaJpZM4XXH2W .

erfanfaramarzi avatar Dec 05 '18 03:12 erfanfaramarzi

Yes! What i meant to say that i’ll work to solve this issue and add the search feature into the application! But I guess you guys should approve first before i start the implementation of it :)?

Nourhanjx avatar Dec 05 '18 10:12 Nourhanjx

I can't understand you. Can you tell me how?

erfanfaramarzi avatar Dec 05 '18 11:12 erfanfaramarzi

Would you mind please how you can search through a pdf in android???

erfanfaramarzi avatar Dec 06 '18 04:12 erfanfaramarzi

@Nourhanjx how i can help you? and what do you mean by approve first? what need to approve.

pavelsust avatar Dec 06 '18 07:12 pavelsust

I want to search through PDF file. Is it possible to tell me how

On Thu, Dec 6, 2018 at 11:16 AM Md.Masud Parvez [email protected] wrote:

@Nourhanjx https://github.com/Nourhanjx how i can help you? and what do you mean by approve first? what need to approve.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/barteksc/AndroidPdfViewer/issues/697#issuecomment-444778896, or mute the thread https://github.com/notifications/unsubscribe-auth/AqpjLVU2qL9kw-dC3K5rCA2n0DvbXfuUks5u2MtvgaJpZM4XXH2W .

erfanfaramarzi avatar Dec 06 '18 07:12 erfanfaramarzi

Yes! What i meant to say that i’ll work to solve this issue and add the search feature into the application! But I guess you guys should approve first before i start the implementation of it :)?

I don't think you need any approval to fork the code or implement your solution. You check check it out and make changes.

hammadkhan avatar Dec 06 '19 15:12 hammadkhan

how can we add a search in pdfview

kunang15 avatar May 01 '20 12:05 kunang15

how can we add a search in textview also

kunang15 avatar May 01 '20 12:05 kunang15

any one can help me to highlight text or paragraph while reading pdf ? Let me know how to code it

shivchand avatar Jul 13 '20 18:07 shivchand

Though i like this library very much. But i need a feature like search text in pdf and keyword will be highlighted and go to that page where keyword found.

Did u find any?

Mukhtarali6121 avatar Dec 29 '20 08:12 Mukhtarali6121

Hlo, Is it possible to Search a word and Indexing in this library...?

lijusparkt avatar Jan 12 '21 13:01 lijusparkt

This thread is still active. Hopefully someone can provide us solution for good. :+1:

sca0610 avatar Feb 07 '21 17:02 sca0610

look here and here

implementation 'com.google.android.gms:play-services-vision:20.1.3' // search from pdf

 ParcelFileDescriptor fileDescriptor2 = getContentResolver().openFileDescriptor(Uri.parse(getSource), "r");
 PdfRenderer pdfRenderer = new PdfRenderer(fileDescriptor2);

 for (int i=0; i<pdfRenderer.getPageCount(); i++) {
      PdfRenderer.Page page = pdfRenderer.openPage(i);
      Bitmap bmp = Bitmap.createBitmap(page.getWidth(), page.getHeight(), Bitmap.Config.ARGB_8888);
      page.render(bmp, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);

      TextRecognizer textRecognizer = new TextRecognizer.Builder(getApplicationContext()).build();
      Frame imageFrame = new Frame.Builder().setBitmap(bmp).build();
      String imageText = "";
      SparseArray<TextBlock> textBlocks = textRecognizer.detect(imageFrame);
  
      for (int j = 0; j < textBlocks.size(); j++) {
            TextBlock textBlock = textBlocks.get(textBlocks.keyAt(j));
            imageText = textBlock.getValue();                   // return string
            //Log.i("here", imageText);
       }
       page.close();
 }
 pdfRenderer.close();

necip-yolcu avatar Jul 30 '21 12:07 necip-yolcu

help pls

Sohumkalia3939 avatar Jan 06 '22 12:01 Sohumkalia3939

@ncpy do you have source code to zoom the next textblocks when there are many detected bitmaps?

Attaroqqi avatar Jan 10 '22 23:01 Attaroqqi

Though i like this library very much. But i need a feature like search text in pdf and keyword will be highlighted and go to that page where keyword found.

This app is all ready done anyone can use reverse engineering.

https://play.google.com/store/apps/details?id=pdf.reader.pdfviewer.pdfeditor

vimalcvs avatar Aug 04 '22 04:08 vimalcvs

pdfium should have this function, the problem is to implement it for android. I remember the old app "google pdf viewer" which however was based on pdfium and had this function

I did some research and found some libraries that have implemented the search, but I don't know if they work, they should be tested. It would take someone to test them and maybe fork and keep an updated fork.

Test them and let me know if they work in any way

https://github.com/gulshan98185/AndroidPdfViewer

https://github.com/beeline09/AdvancedPdfView

https://github.com/beeline09/android-support-pdfium

https://github.com/benjinus/android-support-pdfium

odmfl avatar Oct 20 '22 13:10 odmfl