Skip to content

Code samples

Handling sessions in the multipage processing mode

The code snippet below demonstrates how to interrupt the scanning processing after the page of the document is processed (e.g. for showing a custom screen), and then start scanning of the next one:

override fun onResume() {
    super.onResume()

    // set setManualMultipageMode to true and multipageProcessing to false
    DocumentReader.Instance().functionality().edit().setManualMultipageMode(true).apply()
    DocumentReader.Instance().processParams().multipageProcessing = false

    DocumentReader.Instance().startNewSession()
    showScanner()
}

private fun showScanner() {
    DocumentReader.Instance().showScanner(this@MainActivity) { action, results, error ->
        if (action == DocReaderAction.COMPLETE) {
            if (results.morePagesAvailable != 0) {
                DocumentReader.Instance().startNewPage()
                showScanner()
            }
        }
    }
}
Back to top