The document scanning control provides the service of taking photos of documents and converting them into high-definition scanned copies. Users can capture document photos with their phones, and these photos can be automatically clipped, optimized, and then saved or shared as JPEG images or PDF files. Users can also use this service to identify forms from photos just taken or in the gallery and generate form documents.
Start version: 5.0.0(12)
import { DocType, DocumentScanner, DocumentScannerConfig, SaveOption, FilterId, ShootingMode } from "@kit.VisionKit"; Document scanning control, which can be integrated to implement document scanning.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Parameters:
Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
scannerConfig | No | No | Document scanning capability configuration. | |
onResult | No | No | Callback of the document scanning result. |
Document scanning capability configuration.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
supportType | DocType[] | No | No | Supported file types. The default value is [DocType.DOC]. |
maxShotCount | number | No | Yes | Maximum number of document photos captured each time. The default value is 1. |
isGallerySupported | boolean | No | Yes | Indicates whether images can be selected from the gallery.
The default value is true. |
defaultFilterId | No | Yes | Initial filter effect. By default, the enhanced filter is used. | |
defaultShootingMode | No | Yes | Initial shooting mode. By default, manual shooting is used. | |
editTabs | EditTab[] | No | Yes | Button displayed in the tab bar. By default, all buttons are displayed. |
isShareable | boolean | No | Yes | Indicates whether the sharing function is supported.
The default value is true. |
saveOptions | No | Yes | File format for saving scanning results. By default, all options are selected. The PDF format is not supported currently. | |
originalUris | string[] | No | Yes | Initial image list. If the value is not empty, the value is used to jump to the editing screen. By default, the value is empty. |
Enumeration of supported file types.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Name | Value | Description |
|---|---|---|
DOC | 0 | Document. |
SHEET | 1 | Form. |
Enumeration of filters added to images.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Name | Value | Description |
|---|---|---|
ORIGINAL | 0 | Original image filter. |
MONOCHROME | 1 | Black and white filter. |
STRENGTHEN | 2 | Enhanced filter. |
Enumeration of photo shooting modes.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Name | Value | Description |
|---|---|---|
AUTO | 0 | Automatic shooting mode. |
MANUAL | 1 | Manual shooting mode. |
Enumeration of buttons in the tab bar.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Name | Value | Description |
|---|---|---|
ROTATE_TAB | 0 | Rotate button. |
DELETE_TAB | 1 | Delete button. |
RESHOOT_TAB | 2 | Reshoot button. |
Enumeration of file formats for saving scanning results.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Name | Value | Description |
|---|---|---|
JPG | 0 | JPEG. |
1 | PDF. | |
EXCEL | 2 | Excel. |
DocumentScannerResultCallback = (code: number, saveType: SaveOption, uris: string[]) => void
Callback of the document scanning result.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.AI.Component.DocScan
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
code | number | Yes | The value -1 indicates that no result is returned, and the value 200 indicates that the result is normally returned. |
saveType | Yes | Format in which the result is saved. | |
uris | string[] | Yes | Document URI list. |