Search code examples
androidpdf-viewerpdfview

Open pdf file in Android and search for word in it


I want to be able to open pdf files in my android and search for a specific word either in English or Arabic.. how to do that in code and what is the best pdf viewer to do search?


Solution

  • Try This to open a pdf file

    File pdfFile = new File("path"); 
                    if(pdfFile.exists()) 
                    {
                        Uri path = Uri.fromFile(pdfFile); 
                        Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
                        pdfIntent.setDataAndType(path, "application/pdf");
                        pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    
                        try
                        {
                            startActivity(pdfIntent);
                        }
                        catch(ActivityNotFoundException e)
                        {
                            Toast.makeText(MyPDFDemo.this, "No Application available to view pdf", Toast.LENGTH_LONG).show(); 
                        }
                    }
    

    You can find PDF reader based on your requirement from this link

    Plz let me know if this solution suits your need