loadFileAsync()

Description

Loads images or documents to DcsBuffer.

Syntax

func loadFileAsync(file:String, mode:DcsModeEnum, onSuccess:onLoadSuccess, onFailure:onLoadFailure, onProgress: onLoadProgress)

Parameters

file:String The files to be loaded in buffer in jpg, png or pdf formats.
mode:DcsModeEnum The format for loading images. The values represent whether it's in an image or document format.
onSuccess:onLoadSuccess The callback function when this method performs successfully.
onFailure:onLoadFailure The callback function when this method performs unsuccessfully.
onProgress:onLoadProgress The callback function when this method push load progress info. It's triggered whenever
the data is read. When YES is returned, loadAsync will keep executing. When NO is returned, loadAsync will stop and DcsOperationCancelledException will be thrown. The returned value progress shows the progress in percentage.

Return value

Void

Exceptions

Circumstance Exception thrown
License verification failed. DcsLicenseVerificationFailedException
There is error reading the file. DcsFileReadException
Data is nil. DcsValueNotValidException
The content of the file can't be decoded. DcsDataFormatInvalidException
mode is not DME_IMAGE nor DME_DOCUMENT. DcsValueOutOfRangeException
onLoadSuccess = (source: Any) -> Void
Description This event is triggered when loadAsync function is successfully executed.
Parameter source: The source of the data. It represents the file name or the buffer stream loadAsync loaded.
typealias onLoadFailure = (source: Any, exp: DcsException) -> Void
Description This event is triggered when loadAsync function is not successfully executed.
Parameter source: The source of the data. It represents the file name or the buffer stream loadAsync loaded.
exp: The exception loadAsync throws.
onLoadProgress = (progress: Int) -> Bool
Description This event is triggered when loadAsync function is executing and showing the progress.
Parameter progress: The progress of loading files.
Return When YES is returned, loadAsync will keep executing. When NO is returned, loadAsync will stop.