Scandit.Annotation

new Annotation()

Creates a new instance of Annotation

Examples
  • JavaScript
  • ES6
var annotation = new Scandit.Annotation();
const annotation = new Scandit.Annotation();

Methods

capture(): Promise<Scandit.Annotation.AnnotationResult>

Allows the user to annotate an image and capture the result. The result image is only available until the activity is closed.

Returns:
Promise<Scandit.Annotation.AnnotationResult>

Promise which is resolved to an annotation result object

Can return error with code:

Examples
  • JavaScript
  • ES6
var annotation = new Scandit.Annotation();
// assuming that `imagePath` is defined and is a valid path to an image file

annotation.capture(imagePath).then(function(result) {
  console.log('Annotation is captured, the image file is now saved at ' + result.url);
});
const annotation = new Scandit.Annotation();
// assuming that `imagePath` is defined and is a valid path to an image file

annotation.capture(imagePath).then(result => {
  console.log(`Signature is captured, the image file is now saved at ${result.url}`);
});

close()

Closes the annotation capture screen

Examples
  • JavaScript
  • ES6
var annotation = new Scandit.Annotation();
// assuming that `imagePath` is defined and is a valid path to an image file

annotation.capture(imagePath).then(function(result) {
  console.log('Annotation is captured, the image file is now saved at ' + result.url);
});

// assuming that `shouldCloseAnnotationCapture` is defined and set based on some conditions that determine
// if the annotation capture screen should be closed before the user is done capturing the annotation
if (shouldCloseAnnotationCapture) { annotation.close(); }
var annotation = new Scandit.Annotation();
// assuming that `imagePath` is defined and is a valid path to an image file

annotation.capture(imagePath).then(result => {
  console.log(`Annotation is captured, the image file is now saved at ${result.url}`);
});

// assuming that `shouldCloseAnnotationCapture` is defined and set based on some conditions that determine
// if the annotation capture screen should be closed before the user is done capturing the annotation
if (shouldCloseAnnotationCapture) { annotation.close(); }

continue(data: object): Promise<Scandit.Annotation.AnnotationResult>

Allows the user to continue annotating a previously annotated image and capture the result. The result image is only available until the activity is closed.

Parameters:
Name Type Description
data object

Annotation data, including the original image and the history (AnnotationResult.data)

Returns:
Promise<Scandit.Annotation.AnnotationResult>

Promise which is resolved to an annotation result object

Can return error with code:

Examples
  • JavaScript
  • ES6
var annotation = new Scandit.Annotation();
// assuming that `imagePath` is defined and is a valid path to an image file

annotation.capture(imagePath, {extended: true})
  .then(function(result) {
    console.log('Annotation is captured, the image file is now saved at ' + result.url);
    return annotation.continue(result.data);
  })
  .then(function(editedResult) {
    console.log('Annotation was further edited and captured, the image file is now saved at ' + editedResult.url);
  });
const annotation = new Scandit.Annotation();
// assuming that `imagePath` is defined and is a valid path to an image file

annotation.capture(imagePath, {extended: true})
  .then(result => {
    console.log(`Annotation is captured, the image file is now saved at ${result.url}`);
    return annotation.continue(result.data);
  })
  .then(editedResult => {
    console.log('Annotation was further edited and captured, the image file is now saved at ${editedResult.url}');
  });

Type Definitions

AnnotationResult

Properties:
Name Type Attributes Description
url string

Path to the annotated image

data string <optional>

Annotation data. Only present if set to return extended results.

Properties
Name Type Attributes Description
originalImage string <optional>

Base64 encoded image data (Only present if set to return extended results)

history object <optional>

Annotation history (Only present if set to return extended results)