AndroidPdfViewer icon indicating copy to clipboard operation
AndroidPdfViewer copied to clipboard

Search Text Inside PDF

Open nusagates opened this issue 6 years ago • 18 comments

Hi, could we search text inside pdf?

nusagates avatar May 07 '18 03:05 nusagates

the code has not been wrote yet, but feel free to submit any development you can add to doing this.

1stmetro avatar May 07 '18 17:05 1stmetro

Ya search text feature is needed to me too

Sumit-Chakole avatar May 22 '18 08:05 Sumit-Chakole

me to, is it easy? seems it's a common function

liupeng826 avatar Jun 11 '18 11:06 liupeng826

i need this feature too, please add

ghost1372 avatar Jul 07 '18 08:07 ghost1372

i need this too. please add this feature or help how we can do it. thanks

dvMadMan avatar Jul 14 '18 10:07 dvMadMan

@dvMadMan i found a better way to render pdf files on android with auto search ability if you want to know tell me know

ghost1372 avatar Jul 14 '18 10:07 ghost1372

@ghost1372 How?

AhmerAfzal1 avatar Jul 14 '18 10:07 AhmerAfzal1

@AhmerAfzal1 you must use javascript library just download and copy pdfjs lib in your assets folder then put a webview in your activity in last step show your pdf like this:

  webview = (WebView) findViewById(R.id.webview);
            WebSettings settings = webview.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setAllowFileAccessFromFileURLs(true);
            settings.setAllowUniversalAccessFromFileURLs(true);
            settings.setBuiltInZoomControls(true);
            webview.setWebChromeClient(new WebChromeClient());
            webview.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + pdfPath);

note: library must be this folder like this:
Assets-->pdfjs--> build web Mozilla Pdfjs

ghost1372 avatar Jul 14 '18 10:07 ghost1372

@ghost1372 this way is very slow for my phone. this AndroidPdfViewer better, but need search ))))

dvMadMan avatar Jul 14 '18 20:07 dvMadMan

@dvMadMan yes because use webview and js, so its slow, but it has automatic search functionality And the much smaller size of this library.

ghost1372 avatar Jul 15 '18 07:07 ghost1372

Thank you! @ghost1372 but we need this function built in this library.

AhmerAfzal1 avatar Jul 15 '18 08:07 AhmerAfzal1

@AhmerAfzal1 @dvMadMan @liupeng826 @nusagates @1stmetro @Sumit-Chakole i found a solution for this check this repo https://github.com/foobnix/LibreraReader it can read and search pdf files with MuPDF lib maybe @barteksc can analysis this repo and add this

ghost1372 avatar Aug 21 '18 07:08 ghost1372

Opensource version od MuPDF od licensed under AGPL license, which requires you to publish source code of your app

barteksc avatar Aug 21 '18 07:08 barteksc

@barteksc i dont have problem with this all of my works is free and open source

ghost1372 avatar Aug 21 '18 07:08 ghost1372

@barteksc , is there any chance of getting search feature in Pdfviewer library?

BharathPujariMize avatar May 24 '21 08:05 BharathPujariMize

Try this https://github.com/thevikke/read_pdf_text/blob/master/android/src/main/java/com/example/read_pdf_text/ReadPdfTextPlugin.java

Taron133 avatar Feb 03 '22 20:02 Taron133

@ghost1372 How?

https://github.com/vimalcvs/PDFTextSearch/blob/main/app/src/main/java/com/example/pdftextsearch/MainActivity.java

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