Document

class Document

Represents a document.

Constructors

Link copied to clipboard
constructor(documentStorage: DocumentStorage, pageFileStorage: PageFileStorage, fileIOProcessor: FileIOProcessor)
constructor(documentStorage: DocumentStorage, pageFileStorage: PageFileStorage, fileIOProcessor: FileIOProcessor, documentImageSizeLimit: Int)
constructor(documentStorage: DocumentStorage, pageFileStorage: PageFileStorage, fileIOProcessor: FileIOProcessor, documentId: String, createIfNotExist: Boolean = false, documentImageSizeLimit: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The creation timestamp of the document.

Link copied to clipboard

The MAX document image size limit. By default 0 - means original image size will be used.

Link copied to clipboard

The number of pages in the document.

Link copied to clipboard

The list of pages in the document.

Link copied to clipboard
val pagesFlow: <Error class: unknown class><List<Page>>

The flow of pages in the document.

Link copied to clipboard
val pdfUri: Uri

The URI of the default destination location for PDF rendering.

Link copied to clipboard

The URI of the default destination location for TIFF rendering.

Link copied to clipboard

The unique identifier of the document.

Functions

Link copied to clipboard
fun addPage(image: Bitmap): Page
fun addPage(imageUri: Uri): Page
fun addPage(image: ByteArray): Page

Adds original image in the storage, and returns pageId. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard

Creates a deep copy of the existing document with a new unique UUID, adjust JSON to new UUID and return the newly created Document. Creates a deep copy of the each page with a new unique UUIDs. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun delete()

Deletes the document. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun duplicate(newUuid: String = UUID.randomUUID().toString(), overwrite: Boolean = true): Document

Copy document folder recursively under a new uuid, adjust JSON to newUuid and return the newly created Document. Creates a deep copy of the each page with a new unique UUIDs. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun insertPage(image: Bitmap, index: Int): Page
fun insertPage(image: ByteArray, index: Int): Page

Inserts original image with the given index, and returns Page. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun loadSync(createIfNotExist: Boolean = false): Document?

Loads the document synchronously. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun movePage(sourceIndex: Int, destinationIndex: Int): Boolean

Move the page with the given index to the destination index. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun pageAtIndex(index: Int): Page?

Returns the page with the given index.

Link copied to clipboard

Returns the list of ids of the pages.

Link copied to clipboard
fun pageWithId(uuid: String): Page?

Returns the page with the given id.

Link copied to clipboard

Remove all page from the document at one batch operation. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun removePage(page: Page): Boolean

Remove the given page. This is an IO operation and is not recommended to execute in the UI thread.

fun removePage(atIndex: Int): Boolean

Remove the page with the given index. This is an IO operation and is not recommended to execute in the UI thread.

fun removePage(pageUuid: String): Boolean

Remove the page with the given id. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun saveSync()

Saves the document synchronously. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun sortPagesById(pageIds: List<String>)

Rearranges the order of pages due to order of passed Page IDs. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard
fun toJson(): String

Returns the JSON representation of the document.