DImuthuUpe / AndroidPdfViewer

Android view for displaying PDFs rendered with PdfiumAndroid
Apache License 2.0
8.18k stars 1.91k forks source link

Text search in pdf #697

Open pavelsust opened 6 years ago

pavelsust commented 6 years ago

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.

erfanfaramarzi commented 6 years ago

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?

pavelsust commented 6 years ago

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

Nourhanjx commented 5 years ago

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 :)!

erfanfaramarzi commented 5 years ago

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 notifications@github.com 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 .

Nourhanjx commented 5 years ago

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 :)?

erfanfaramarzi commented 5 years ago

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

erfanfaramarzi commented 5 years ago

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

pavelsust commented 5 years ago

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

erfanfaramarzi commented 5 years ago

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 notifications@github.com 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 .

hammadkhan commented 4 years ago

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.

kunang15 commented 4 years ago

how can we add a search in pdfview

kunang15 commented 4 years ago

how can we add a search in textview also

shivchand commented 4 years ago

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

Mukhtarali6121 commented 3 years ago

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?

lijusparkt commented 3 years ago

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

sca0610 commented 3 years ago

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

necip-yolcu commented 3 years ago

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();
Sohumkalia3939 commented 2 years ago

help pls

Attaroqqi commented 2 years ago

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

vimalcvs commented 2 years ago

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

odmfl commented 2 years ago

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