-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fb689f9
Showing
41 changed files
with
1,501 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Asutosh11 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
[![](https://jitpack.io/v/Asutosh11/DocumentReader.svg)](https://jitpack.io/#Asutosh11/DocumentReader) | ||
|
||
|
||
# DocumentReader | ||
|
||
This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String. | ||
|
||
<i>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.</i> | ||
|
||
<p><b>How to import in gradle?</b></p> | ||
|
||
|
||
1.<code> | ||
repositories { | ||
... | ||
maven { url 'https://jitpack.io' } | ||
} | ||
</code><br/> | ||
|
||
2.<code> | ||
dependencies { | ||
.... | ||
implementation 'com.github.Asutosh11:DocumentReader:0.1' | ||
} | ||
</code> | ||
|
||
<p><b>Usage in code</b></p> | ||
|
||
// 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 -> "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.github.dcendents.android-maven' | ||
group = 'com.github.asutosh11' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
|
||
packagingOptions { | ||
exclude 'META-INF/DEPENDENCIES' | ||
exclude 'META-INF/INDEX.LIST' | ||
exclude 'META-INF/spring.handlers' | ||
exclude 'META-INF/spring.schemas' | ||
exclude 'META-INF/cxf/bus-extensions.txt' | ||
} | ||
|
||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'androidx.core:core-ktx:1.3.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
|
||
implementation 'androidx.multidex:multidex:2.0.1' | ||
|
||
implementation (group: 'org.apache.tika', name: 'tika-parsers', version: '1.14'){ | ||
exclude group: "org.apache.xmlbeans" | ||
['org.apache.commons','commons-logging'].each { | ||
exclude group: "$it" | ||
} | ||
} | ||
implementation 'javax.xml.stream:stax-api:1.0' | ||
implementation group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '3.0.1' | ||
implementation 'com.tom_roush:pdfbox-android:1.8.10.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
Oops, something went wrong.