Skip to main content

Detecting documents on an image with the Web Document Scanner SDK

Overview​

You can directly run document detection on an image or page and process the results in your own custom UI. This provides flexibility for integrating document detection capabilities into a broader range of applications and user interfaces.

async detectDocument(
image: Image,
config: DocumentScannerConfiguration = {},
consumeType: ConsumeType = 'COPY_IMAGE'
): Promise<Config.DocumentDetectionResult | null> {

Please refer to the API documentation for details on the config and return types.

Example of performing document detection on a page​

...
const reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = async (e) => {
const image = ScanbotSDK.Config.Image.fromEncodedBinaryData(reader.result as ArrayBuffer);
const result = await this.sdk.detectDocument(image);
if (result.detectionResult.status === "OK") {
const processor = await this.sdk.createImageProcessor();
const cropped = await processor.crop(image, result.detectionResult.pointsNormalized);
...
} else {
...
};

Want to scan longer than one minute?

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

Get free trial license