Skip to main content

Document Capture

This module provides a way to clip and upload the generic documents such as proof of adress, adhering to the desired document type, count, and screen configuration. Document type specifies the type of the document to be loaded and the document builder specifies the display configurations such as colors, text, and how many documents will be taken from camera.

Starting the capture

To capture a document from camera and let the user crop it use the start() method of this module.

User Interface Settings

// Preparing DocumentBuilder for User Interface && Some Logic Operations
val docBuilder = DocBuilder(
tryAgainText = "Tekrar Dene", // Text label
confirmText = "Onayla", // Text label
tryAgainTextColor = R.color.color_blue, // Text color
confirmTextColor = R.color.color_blue, // Text color
captureButtonColor = R.color.white, // Button color
documentCount = 2
) // Indicates the number of documents.
//Calling Generic Document Fragment and Uploading Documents
val docFragment = Amani.sharedInstance().Document()
.start(
docType = "DOC_TYPE",
documentBuilder = docBuilder,
frameLayout = frameLayout ,
callBack = object : IDocumentCallBack{
override fun cb(
listOfDocumentAbsolutePath: ArrayList<String>?,
isSuccess: Boolean
) {
Amani.sharedInstance().Document().upload(
activity = this,
docType = "DOC_TYPE",
callBack = object : IUploadCallBack {
override fun cb(isSuccess: Boolean) {
//Document is uploaded successfully
}
}
)
}
}
)

replaceFragmentWithBackStack(R.id.id_frame_layout, docFragment)

Uploading Generic Documents

If you don't want to use the built in crop screen or upload supported file formats directly you can use the methods shown below.

note

Supported file types are:

  • application/pdf
  • jpg
  • png
  • webp
  • bmp
 val docData1 = FileWithType(                                                                       
byteArray = byteArrayOfPdf,
type = "application/pdf"
) // An object data class first param: byteArray, second param: type (file type: jpeg,pdf,png etc.)

val docData2 = FileWithType(
byteArray = byteArrayOfJpeg,
type = "jpeg"
)

val docDataList = arrayListOf(
docData1,
docData2
)

Amani.sharedInstance().Document().upload(
activity = this,
docType = "DOC_TYPE",
data = docDataList,
callBack = object : IUploadCallBack{
override fun cb(isSuccess: Boolean) {
//If isSuccess true document is uploaded successfully
}
})

Deleting Document Cache Files (Optional usage, NOT Required!)

It provides a way to delete all file that are taken from camera. If you want to call this, you must call this after the upload process is done. Otherwise upload will fail.

Amani.sharedInstance().Document().deleteAllDocumentCaches()