loadFileAsync()

Description

Loads images from files asynchronously and converts them to dcsImage or dcsDocument in DcsBuffer according to the value of mode.

Syntax

(void) loadFileAsync: (NSString *)file
data mode: DcsModeEnum mode
successCallback: (onLoadSuccess) onSuccess
failureCallback: (onLoadFailure) onFailure
progressCallback: (onLoadProgress) onProgress

Parameters

data:NSString The file to be loaded. It must be a jpg, png or pdf.
mode:DcsModeEnum The format for the loading image. The values represent whether it's an image or a document.
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 pushes load progress information. This parameter is mainly used for processing multi-page PDFs. This function will be triggered when a number of PDF files are loaded. When false is returned, the loading will be terminated.

Return value

Void

Exceptions

Circumstance Exception thrown
License verification failed. DcsLicenseVerificationFailedException
There is error decoding the data DcsDataFormatInvalidException
File is nil DcsValueNotValidException
Mode is not DME_DOCUMENT nor DME_IMAGE. DcsValueOutOfRangeException
void (^onLoadSuccess) (id source)
Description This event is triggered when loadFileAsync function is successfully executed.
Parameter source: The source of the data. It represents the file name or the buffer stream loadFileAsync loaded.
void (^onLoadFailure) (id source, DcsException *exp)
Description This event is triggered when loadFileAsync function is not successfully executed.
Parameter source: The source of the data. It represents the file name or the buffer stream loadFileAsync loaded.
exp: The exception loadFileAsync throws.
BOOL (^onLoadProgress) (NSInteger progress)
Description This event is triggered when loadFileAsync function is executing and showing the progress.
Parameter progress: The progress of loading files.
Return When YES is returned, loadFileAsync will keep executing. When NO is returned, loadFileAsync will stop.