Skip to main content

Storage for Pages

Scanned Document

The Scanbot SDK provides a scanned document container class for scanned and imported pages. It can be used to store and retrieve scanned pages to and from the device disk.

Example of storing and retrieving an SBSDKScannedDocument

Storing and retrieving an SBSDKScannedDocument
loading...

Image storing

The document pages display the scanned images, and these images can be stored using indexed or keyed image storages.

  • Those storages are thread-safe and persistent storages for images.
  • They can be used to store and retrieve images in an array-fashioned style (indexed) or dictionary-fashioned style (keyed) to and from the device disk.
  • Both allow the usage of an encrypter which encrypts the data when writing it to the disk and decrypts the data when reading it from the disk.
  • Custom image storages can be implemented and used within Scanbot SDK by conforming to the storing protocol.

Example of storing images using SBSDKIndexedImageStorage

Storing images using SBSDKIndexedImageStorage
loading...

Migration from SBSDKDocument (RTU UI v1) to SBSDKScannedDocument (RTU UI v2)

In contrast to the previous SBSDKDocument in RTU UI v1, which served as a thread-safe, mutable container for SBSDKDocumentPage instances, the new model SBSDKScannedDocument in RTU UI v2 offers significant advancements in many ways but specially in terms of persistence and observability. The former implementation did not support automatic persistence, and observability was limited to changes in the number of pages only, restricting dynamic updates to the user interface.

The new model SBSDKScannedDocument, however, is an automatically persisted, thread-safe and observable document-page model for a document with multiple scanned pages of type SBSDKScannedPage. Enabling a more seamless and responsive user experience by ensuring real-time updates in response to modifications at any level.

Each page consists of an original image of the scan, various editing properties like cropping polygon, rotation and filters, some metadata properties like the document detection status and the document quality analyzer result and a number of processed images in different stages. The editing properties of each page can be used to manipulate its final document image in a non-destructive way. The scanned pages can be organized (added, removed and moved) within the scanned document.

The scanned document automatically persists itself, including its pages and their images, on the disk, so that you can access and modify the scanned document, its pages and images across numerous app sessions. Various functions allow you to enumerate, load and delete your scanned documents.

Your app's user interface can easily observe documents and even individual pages to automatically refresh upon changes made to the scanned document or its pages.

You can easily migrate from the old model to the new model using the provided initializer on the new model. Take a look at the example below:

func createFromDocument(_ document: SBSDKDocument) -> SBSDKScannedDocument? {

// Create the scanned document using convenience initializer `init?(document:documentImageSizeLimit:)`
// `SBSDKDocument` doesn't support `documentImageSizeLimit`, but you can add it to unify size of the documents.
let scannedDocument = SBSDKScannedDocument(document: document, documentImageSizeLimit: 2048)

// Return newly created scanned document
return scannedDocument
}

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get your free Trial License

What do you think of this documentation?