captureSignatureWithHandler(errorCallback, options)

Similar to the captureSignature() method, this method starts capturing a signature but returns a handler (asynchronously) instead.

The handler can be used to execute apply, cancel, and erase actions from the calling application.

This method should be used if capturing is done in embedded mode (options contain embedCanvasIn) with external UI actions.

Input parameter

  • errorCallback (the function called by the library when an error occurs during capturing).
  • Options object (optional). See captureSignature() method for options description.

Returns

A handler object as Promise, supporting the following methods.

  • isActive()

    Returns true if signature capture process is active. Else, false is returned.

  • erase()

    Erases the currently captured signature. Throws an error if capture process is not active.

  • cancel()

    Cancels the current capture process. Throws an error if capture process is not active.

  • apply{}

    Applies the currently captured signature and returns the capture result object asynchronously. See captureSignature() method for capture result description.

    Throws an error if capture process is not active (promise is rejected in that case).

Example

The following example assumes that the web page consists of a div element with id ‘signature’ and three button elements whose onclick handlers call methods erase(), cancel() and apply().

let signatureCaptureHandler;
const deviceConnector = new deviceconnector.DeviceConnector();
    const sigOptions = {
        captureStrategy: 'HTML5_ONLY',
        embedCanvasIn: document.getElementById('signature'),
        embeddedCanvasBehavesModal: false,
        html5CaptureOptions: {
            showSignatureLine: true,
            signatureLineText: 'Please sign here',
            showCancel: false,
            showErase: false,
            showApply: false
        }
    }
        deviceConnector.captureSignatureWithHandler(errorCallback, sigOptions).then((handler) => {
            signatureCaptureHandler = handler;
       	}).catch((err) => {
            // Handle unexpected error
        });
        function errorCallback(err) {
            // Handle unexpected error
        }
        function erase() {
            if (signatureCaptureHandler) {
                signatureCaptureHandler.erase();
            }
        }
        function cancel() {
            if (signatureCaptureHandler) {
                signatureCaptureHandler.cancel();
            }
        }
        function apply() {
            if (signatureCaptureHandler) {
                signatureCaptureHandler.apply().then((result) => {
                    // Handle result  if (result.action === 'OK') { 
       	        var isoSignature = result.signature; 
       	            // Process signature...
                });
            }
        }