DocumentReader
This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String.
Install / Use
/learn @Asutosh11/DocumentReaderREADME
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>
<br><h3><b>Dependency for build.gradle (Project level)</b></h3>
repositories {
...
maven { url 'https://jitpack.io' }
}
<br><h3><b>Dependency for build.gradle (Module: app)</b></h3>
dependencies {
....
implementation 'com.github.Asutosh11:DocumentReader:0.12'
// NOTE: use this only if you get a multidex exception
implementation "androidx.multidex:multidex:2.0.1"
}
// NOTE: use this only if you get an error like - More than one file was found with OS independent path
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'
}
// NOTE: use this only if you get a multidex exception
defaultConfig {
...
multiDexEnabled true
}
<br><h3><b>How to use it?</b></h3>
// Read a pdf file from Uri
val docString : String = DocumentReaderUtil.readPdfFromUri(fileUri, applicationContext)
// Read a pdf file from File
val docString : String = DocumentReaderUtil.readPdfFromFile(file, applicationContext)
// read a doc file from Uri
val docString : String = DocumentReaderUtil.readWordDocFromUri(fileUri, applicationContext)
// read a doc file from File
val docString : String = DocumentReaderUtil.readWordDocFromFile(file, applicationContext)
// read a docx file from Uri
val docString : String = DocumentReaderUtil.readWordDocFromUri(fileUri, applicationContext)
// read a docx file from File
val docString : String = DocumentReaderUtil.readWordDocFromFile(file, applicationContext)
// read a txt file from Uri
val docString : String = DocumentReaderUtil.readTxtFromUri(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(fileUri, applicationContext)) {
"text/plain" -> DocumentReaderUtil.readTxtFromUri(fileUri, applicationContext)
"application/pdf" -> DocumentReaderUtil.readPdfFromUri(fileUri, applicationContext)
"application/msword" -> DocumentReaderUtil.readWordDocFromUri(fileUri, applicationContext)
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" ->
DocumentReaderUtil.readWordDocFromUri(fileUri, applicationContext)
else -> ""
}
<br>
<h2><b>Thanks</b></h2>
<a href = "https://tika.apache.org/">The Apache Tika project</a><br>
<a href = "https://github.com/TomRoush/PdfBox-Android">Apache's PdfBox port by TomRoush</a>Related Skills
docs-writer
99.6k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
341.8kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
summarize
341.8kSummarize or extract text/transcripts from URLs, podcasts, and local files (great fallback for “transcribe this YouTube/video”).
feishu-doc
341.8k|
