Skip to content

Commit fb689f9

Browse files
committed
Initial commit
0 parents  commit fb689f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1501
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

.idea/codeStyles/Project.xml

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Asutosh11
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[![](https://jitpack.io/v/Asutosh11/DocumentReader.svg)](https://jitpack.io/#Asutosh11/DocumentReader)
2+
3+
4+
# DocumentReader
5+
6+
This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String.
7+
8+
<i>If you have ever tried to read contents of a PDF or MS word document on Android, you know how painful it is.
9+
This library makes your work easy.</i>
10+
11+
<p><b>How to import in gradle?</b></p>
12+
13+
14+
1.<code>
15+
repositories {
16+
...
17+
maven { url 'https://jitpack.io' }
18+
}
19+
</code><br/>
20+
21+
2.<code>
22+
dependencies {
23+
....
24+
implementation 'com.github.Asutosh11:DocumentReader:0.1'
25+
}
26+
</code>
27+
28+
<p><b>Usage in code</b></p>
29+
30+
// Read a pdf file from Uri
31+
val docString : String = DocumentReaderUtil.readPdfFileContent(fileUri, applicationContext)
32+
// Read a pdf file from File
33+
val docString : String = DocumentReaderUtil.readPdfFileContent(file, applicationContext)
34+
35+
// read a doc file from Uri
36+
val docString : String = DocumentReaderUtil.readWordDocFile(fileUri, applicationContext)
37+
// read a doc file from File
38+
val docString : String = DocumentReaderUtil.readWordDocFile(fileUri, applicationContext)
39+
40+
// read a docx file from Uri
41+
val docString : String = DocumentReaderUtil.readWordDocFile(fileUri, applicationContext)
42+
// read a docx file from File
43+
val docString : String = DocumentReaderUtil.readWordDocFile(file, applicationContext)
44+
45+
// read a txt file from Uri
46+
val docString : String = DocumentReaderUtil.readTxtFileContent(fileUri, applicationContext)
47+
48+
/*
49+
Even if you don't know your file type,
50+
this library detects the file mime type and gives you the content of the file as a String
51+
*/
52+
val DocString : String = when (DocumentReaderUtil.getMimeType(file, applicationContext)) {
53+
"text/plain" -> DocumentReaderUtil.readTxtFileContent(file, applicationContext)
54+
"application/pdf" -> DocumentReaderUtil.readPdfFileContent(file, applicationContext)
55+
"application/msword" -> DocumentReaderUtil.readWordDocFile(file, applicationContext)
56+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" ->
57+
DocumentReaderUtil.readWordDocFile(file, applicationContext)
58+
else -> ""
59+
}

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

0 commit comments

Comments
 (0)