Appearance
Mobile Document Scanner API Reference / DocumentScannerConfig
Interface: DocumentScannerConfig
Defined in: src/DocumentScanner.ts:104
The DocumentScannerConfig interface passes settings to the DocumentScanner constructor to apply a comprehensive set of UI and business logic customizations.
Remarks
Only advanced scenarios require editing the UI template or MDS source code. DocumentScannerConfig.license is the only property required to instantiate a DocumentScanner object. MDS uses sensible default values for all other omitted properties.
Example
typescript
const config = {
license: "YOUR_LICENSE_KEY_HERE",
scannerViewConfig: {
cameraEnhancerUIPath: "./dist/document-scanner.ui.xml", // Use the local file
},
engineResourcePaths: {
std: "./dist/libs/dynamsoft-capture-vision-std/dist/",
dip: "./dist/libs/dynamsoft-image-processing/dist/",
core: "./dist/libs/dynamsoft-core/dist/",
license: "./dist/libs/dynamsoft-license/dist/",
cvr: "./dist/libs/dynamsoft-capture-vision-router/dist/",
ddn: "./dist/libs/dynamsoft-document-normalizer/dist/",
},
};Properties
container?
optionalcontainer?:string|HTMLElement
Defined in: src/DocumentScanner.ts:119
The container element or selector for the DocumentScanner UI.
correctionViewConfig?
optionalcorrectionViewConfig?:Omit<DocumentCorrectionViewConfig,"templateFilePath"|"utilizedTemplateNames"|"_showCorrectionView">
Defined in: src/DocumentScanner.ts:174
enableContinuousScanning?
optionalenableContinuousScanning?:boolean
Defined in: src/DocumentScanner.ts:206
Enable continuous scanning mode where the scanner can loop back to capture more documents instead of exiting after a single scan. DocumentScanner.launch only resolves to the last scanned result. Use onDocumentScanned callback to get scan results.
Remarks
When enabled:
- The result view shows a "Scan More" button alongside "Done"; tapping "Scan More" loops back to capture another document, while "Done" ends the session
- The onDocumentScanned callback triggers after each scan with the result; this is the only way to get the scanned results as DocumentScanner.launch only returns the last scanned result
- Users can also exit by clicking the close button (X) or by calling DocumentScanner.stopContinuousScanning
- The DocumentScanner only retains the most recent scan result
- A thumbnail preview of the last scan appears in the camera view, but only when both showCorrectionView and showResultView are disabled (otherwise scans route through those views instead). See onThumbnailClicked to make it clickable.
Default Value
ts
false
@publicenableFrameVerification?
optionalenableFrameVerification?:boolean
Defined in: src/DocumentScanner.ts:272
Enable automatic frame verification for best quality capture.
Remarks
When enabled, uses clarity detection and cross-filtering to automatically find the clearest frame. This uses the same algorithm as the React reference implementation.
Default Value
ts
true
@publicengineResourcePaths?
optionalengineResourcePaths?:EngineResourcePaths
Defined in: src/DocumentScanner.ts:152
Paths to the necessary engine resources (such as .wasm files) for the scanning engine.
Remarks
The default paths point to CDNs so this may be left unset. You may set custom paths to self-host resources or fully self-host MDS.
See
license?
optionallicense?:string
Defined in: src/DocumentScanner.ts:113
The license key for using the DocumentScanner.
Remarks
This is the only required property to instantiate a DocumentScanner object.
onDocumentScanned?
optionalonDocumentScanned?: (result) =>void|Promise<void>
Defined in: src/DocumentScanner.ts:230
Callback invoked after each successful scan in continuous scanning mode.
Parameters
result
The DocumentResult of the scan
Returns
void | Promise<void>
Remarks
This callback is only called when enableContinuousScanning is true, after each scan the user keeps (via either "Scan More" or "Done"). The callback receives a DocumentResult containing the original image, corrected image, detected boundaries, and scan status.
Example
javascript
const documentScanner = new Dynamsoft.DocumentScanner({
license: "YOUR_LICENSE_KEY_HERE",
enableContinuousScanning: true,
onDocumentScanned: async (result) => {
// Process each scanned document
const canvas = result.correctedImageResult.toCanvas();
document.getElementById("results").appendChild(canvas);
}
});onThumbnailClicked?
optionalonThumbnailClicked?: (result) =>void|Promise<void>
Defined in: src/DocumentScanner.ts:261
Callback invoked when the thumbnail preview is clicked in continuous scanning mode.
Parameters
result
The DocumentResult of the last scanned document
Returns
void | Promise<void>
Remarks
The thumbnail preview itself only appears (and this callback only fires) when:
- enableContinuousScanning is enabled
- showCorrectionView is disabled
- showResultView is disabled
The thumbnail displays the most recently scanned document. Defining this callback also gives it a primary-coloured border and pointer cursor; without it, clicking does nothing. Use it to implement custom behaviour such as re-editing the image.
Example
javascript
const documentScanner = new Dynamsoft.DocumentScanner({
license: "YOUR_LICENSE_KEY_HERE",
enableContinuousScanning: true,
showCorrectionView: false,
showResultView: false,
onThumbnailClicked: async (result) => {
// Handle thumbnail click event
console.log('Thumbnail clicked', result);
// Could open a custom editor, display metadata, etc.
}
});resultViewConfig?
optionalresultViewConfig?:DocumentResultViewConfig
Defined in: src/DocumentScanner.ts:173
Configuration settings for the DocumentResultView.
Remarks
See
scannerViewConfig?
optionalscannerViewConfig?:Omit<DocumentScannerViewConfig,"templateFilePath"|"utilizedTemplateNames"|"_showCorrectionView">
Defined in: src/DocumentScanner.ts:161
Configuration settings for the DocumentScannerView.
Remarks
See
showCorrectionView?
optionalshowCorrectionView?:boolean
Defined in: src/DocumentScanner.ts:191
Sets the visibility of the DocumentCorrectionView.
Default Value
ts
true
@publicshowResultView?
optionalshowResultView?:boolean
Defined in: src/DocumentScanner.ts:184
Sets the visibility of the DocumentResultView.
Default Value
ts
true
@publicstringConfig?
optionalstringConfig?:StringConfig
Defined in: src/DocumentScanner.ts:323
Override the default user-facing strings (loading messages, share dialog title, download filename prefix, alert text, etc.).
Remarks
Toolbar button labels (Re-take, Apply, Done, Share, Upload, Correction, Full Image, Detect Borders) are not configured here — use DocumentCorrectionViewConfig.toolbarButtonsConfig and DocumentResultViewConfig.toolbarButtonsConfig for those.
The resolved string config is process-global: instantiating a new DocumentScanner replaces any previously applied config. Running two scanners with different stringConfig values in the same page is not supported — the most recently constructed scanner wins for all of them.
See
StringConfig for the full list of customizable strings.
Example
typescript
new Dynamsoft.DocumentScanner({
license: "YOUR_LICENSE_KEY_HERE",
stringConfig: {
loadingMsg: "Cargando...",
continuousScanDoneBtn: "Listo ({count})",
downloadFilenamePrefix: "invoice",
}
});templateFilePath?
optionaltemplateFilePath?:string
Defined in: src/DocumentScanner.ts:129
The file path to the Capture Vision template used for document scanning.
Remarks
You may set custom paths to self-host the template or fully self-host MDS.
See
themeColor?
optionalthemeColor?:ThemeColor
Defined in: src/DocumentScanner.ts:291
Override the default colors used across all views and the loading screen.
See
ThemeColor for the full list of themeable fields.
Example
typescript
new Dynamsoft.DocumentScanner({
license: "YOUR_LICENSE_KEY_HERE",
themeColor: {
primary: "#0066cc",
backgroundView: "#1a1a1a",
}
});utilizedTemplateNames?
optionalutilizedTemplateNames?:UtilizedTemplateNames
Defined in: src/DocumentScanner.ts:142
Capture Vision template names for document detection and normalization.
Remarks
This typically does not need to be set as MDS provides a default template for general use. You may set custom names to self-host resources or fully self-host MDS.
See
Default Value
DEFAULT_TEMPLATE_NAMES