Document

class Document

Represents a document.

Constructors

Link copied to clipboard
constructor(documentStorage: DocumentStorage, pageFileStorage: PageFileStorage, fileIOProcessor: FileIOProcessor, documentRepository: DocumentRepository)
constructor(documentStorage: DocumentStorage, pageFileStorage: PageFileStorage, fileIOProcessor: FileIOProcessor, documentImageSizeLimit: Int, documentRepository: DocumentRepository)
constructor(documentStorage: DocumentStorage, pageFileStorage: PageFileStorage, fileIOProcessor: FileIOProcessor, documentRepository: DocumentRepository, 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): Result<Page>
fun addPage(imageUri: Uri): Result<Page>
fun addPage(image: ImageRef): Result<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

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): Result<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): Result<Page>
fun insertPage(image: ImageRef, index: Int): Result<Page>
fun insertPage(image: ByteArray, index: Int): Result<Page>

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

Link copied to clipboard
fun loadSync(createIfNotExist: Boolean = false): Result<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): Result<Unit>

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

fun removePage(atIndex: Int): Result<Unit>

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): Result<Unit>

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

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 Result IDs. This is an IO operation and is not recommended to execute in the UI thread.

Link copied to clipboard

Returns the JSON representation of the document.