Giter Site home page Giter Site logo

msoftware / documentreader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asutosh11/documentreader

0.0 1.0 0.0 152 KB

This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String.

License: MIT License

Kotlin 100.00%

documentreader's Introduction

DocumentReader

This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String.

If you have ever tried to read contents of a PDF or MS word document on Android, you know how painful it is. This library makes your work easy.

Dependency for build.gradle (Module: app)

1. repositories { ... maven { url 'https://jitpack.io' } }

2. dependencies { .... implementation 'com.github.Asutosh11:DocumentReader:0.11' }

How to use it?

// Read a pdf file from Uri
val docString : String = DocumentReaderUtil.readPdfFileContent(fileUri, applicationContext)
// Read a pdf file from File
val docString : String = DocumentReaderUtil.readPdfFileContent(file, applicationContext)

// read a doc file from Uri
val docString : String = DocumentReaderUtil.readWordDocFile(fileUri, applicationContext)
// read a doc file from File
val docString : String = DocumentReaderUtil.readWordDocFile(fileUri, applicationContext)

// read a docx file from Uri
val docString : String = DocumentReaderUtil.readWordDocFile(fileUri, applicationContext)
// read a docx file from File
val docString : String = DocumentReaderUtil.readWordDocFile(file, applicationContext)

// read a txt file from Uri
val docString : String = DocumentReaderUtil.readTxtFileContent(fileUri, applicationContext)

/*
Even if you don't know your file type, 
this library detects the file mime type and gives you the content of the file as a String
*/	      
val docString : String = when (DocumentReaderUtil.getMimeType(file, applicationContext)) {
        "text/plain" -> DocumentReaderUtil.readTxtFileContent(file, applicationContext)
        "application/pdf" -> DocumentReaderUtil.readPdfFileContent(file, applicationContext)
        "application/msword" -> DocumentReaderUtil.readWordDocFile(file, applicationContext)
        "application/vnd.openxmlformats-officedocument.wordprocessingml.document" -> 
                                    DocumentReaderUtil.readWordDocFile(file, applicationContext)
         else -> ""
        }

documentreader's People

Contributors

asutosh11 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.