Grayscale image min width
Grayscale image max width
Grayscale image min height
Grayscale image max width
Code39 symbology flags value: require checksum check
Code39 symbology flags value: don't require stop symbol - can lead to false results
Code39 symbology flags value: decode full ASCII
Code39 symbology flags value: Try decoding result to CODE32. if failed, Code39 will return
Code39 symbology flags value: ADD 'A' prefix to Code32 result
Code93 symbology flags value: decode full ASCII
Code25 symbology flags value: require checksum check
NOTE: MWB_CFG_CODE25_REQ_CHKSUM is deprecated and shouldn't be used in combination with other checksum flags
Requires single checksum. Set by default.
Requires double checksum.
Use mod 10 checksum. Set by default.
Use mod 10 mod 10 checksum.
Use mod 11 checksum (IBM algorithm).
Use mod 11 checksum (NCR algorithm).
Use mod 11 mod 10 checksum (IBM algorithm).
Use mod 11 mod 10 checksum (NCR algorithm)
Codabar symbology flags value: include start/stop symbols in result
Datamatrix symbology flags value: enable DPM mode
Telepen symbology flags
Scan color: working for Datamatrix currently
Default for ECI (ECI is DM only)
Default for result prefix (all symbologies except DataBar / RSS)
Default for result prefix for DataBar / RSS only
Default for color (all symbologies)
Global decoder flags value: calculate location for 1D barcodeTypes (Code128, Code93, Code39 supported)
Global decoder flags value: fail 1D decode if result is not confirmed by location expanding (Code128, Code93, Code39 supported)
Global decoder flags value: fail decode if result is not touching the center of viewfinder (2D + Code128, Code93, Code39 supported)
1D locaiton flags will be enabled automatically with this one
Global decoder flags value: disable some image pre-processing, suitable for devices with weak CPU
Global decoder flags value: Enable multiple barcode detection in single image
NOTE: MWB_CODE_MASK_RSS is GS1 DataBar
Standard definition 640x480 camera resolution.
High definition 1280x720 camera resolution.
Full HD 1920x1080 camera resolution.
Note: this option has beed deprecated i.e. it has no effect as camera switcher initialization is always awaited.
⚠️ [Deprecated] The camera switcher initialization happens after a startScanning call, i.e. on creating a cameraPreview. The operation for listing all available cameras is async, thus it can be awaited which ensures the camera list is obtained first before proceeding to starting the camera and scanning, otherwise, it would be executed as asynchronous, where the camera and scanning will be started most likely before the camera list is obtained. This option will await the initialization, thus it will take longer until the camera and scanning is started.
By default the MWBuseFrontCamera setting has priority at picking which camera (back or front) to use on the cameraPreview, and will continue to be the case until a specific camera is picked and switched to from the camera switcher UI. This option will use the first camera from the camera list on the start of the cameraPreview, thus the MWBuseFrontCamera setting would no longer have effect. Using CAMERA_SWITCHER_USE_ON_START also implies CAMERA_SWITCHER_INIT_ON_START.
✨ [Experimental] Devices with multple back cameras may provide the multple back cameras separately rather than as one system, and the wide-angle camera which has no autofocus could be used by default. While there is no official indicator which camera has autofocus, based on observed common denominator in such cases, this option will try to order the multple found cameras such that the main camera which has autofocus will be listed first and used as default.
No overlay is displayed.
Use MW Dynamic Viewfinder with blinking lines.
Show image on top of cameraPreview
No camera preview mirroring is done.
Camera preview mirroring is done only when using front cameras.
Camera preview mirroring is always done.
Nothing happens.
Blinking lines are replaced with a pause view.
Blinking lines stop blinking.
Play a beep sound (requires user input).
The use of startScanning (initiated by user action such as the click of a button, once per session) must precede the use of this method.
Check browser support for features.
By default this method only checks synchronous features.
Some of the features are obtained asynchronously. The check for those features can be enabled by passing their respective parameters.
Check default camera properties and capabilities.
Note: Obtaining camera properties and capabilities requires camera start. This is an async operation and it takes some time to initialize the camera and obtain the result. If camera access permission isn't already granted, this will request user permission.
An object of features needed for cmbWeb and their browser support state.
Support for mediaDevices and getUserMedia APIs.
Starting a camera preview scanning session relies on mediaDevices and getUserMedia.
If not available, live camera scanning with the startScanning method will not be possible.
This can also happen if current context is not secure, see next feature.
Current window is in a secure context.
The mediaDevices and getUserMedia APIs are accessible only in a secure context.
If not available, live camera scanning with the startScanning method will not be possible.
Using the getCameras method will not be possible as well.
💡 Tip: Other scanning methods such as scanImage will still work.
Support for screen.orientation property.
If not available, window size will be used to determine orientation.
Support for WebAssembly.
If not available, cmbWeb will not be able to run.
Support for Web Audio API.
AudioContext is used from the Web Audio API to provide the audio play support across
all browsers and platforms for the beep method.
If not available, HTMLAudioElement will be used as fallback, which may not provide audio
play support across all browsers and platforms due to permission constraints.
Support for camera flash.
This indicates that the browser supports the camera flash feature. The camera device
has to have flash capability for it to actually be used. For example, a front camera may
not always have flash capability.
Camera flash is currently supported only by Chrome.
Support for camera zoom.
This indicates that the browser supports the camera zoom feature. The camera device
has to have zoom capability for it to actually be used. For example, a USB camera may
not always have zoom capability.
Camera zoom is currently supported only by Chrome.
Optional DEFAULT_CAMERA: object
A default camera device is the first camera picked by the browser in case of multiple cameras being present. This will typically be the default back camera on mobile devices.
Any configuration changes, i.e. specifying front camera or setting / selecting a specific camera via setCamera or the camera switcher UI do not affect the default camera.
Properties and capabilities of the default camera device:
LABEL: string
Descriptive label of the camera.
ID: string
Unique id of the camera.
FLASH: boolean
The camera device has flash capability.
ZOOM: boolean
The camera device has zoom capability.
ZOOM_VALUES: boolean
Support for camera provided zoom level values.
If not available, pre-defined values will be used for the zoom levels.
ZOOM_LEVELS: [min: number, mid: number, max: number]
Used zoom levels.
Camera provided zoom levels will be used if available, otherwise, pre-defined values of 100% (min i.e. no zoom), 250% (mid) and 400% (max) will be used.
Close a previously started scan from startScanning.
⚡ A "cameraPreviewClosed" event is triggered when the camera preview is removed from the document body or container element after calling the closeScanner method. See the example event listener.
Returns the ID of the currently used camera, empty string if no camera is used.
Get available cameras for this device.
Get the constants of the scanner so they can be used when calling configuration functions.
Returns an object of cmbWebVersion, decoderVersion and fullVersion.
Load the array of configuration settings. Returns a promise that resolves with the loaded settings.
Should be called in the configuration stage.
Resizes partial scanner cameraPreview dimensions.
If a div element with "cmbweb-preview-container" id is used in the html page, the sdk will detect this and operate in 'container mode' (the cameraPreview will fill the container).
The resizePartialScanner method has no effect in container mode.
X coordinate of left edge (percentage)
Y coordinate of top edge (percentage)
Rectangle witdh (x axis) (percentage)
Rectangle height (y axis) (percentage)
Resumes scanning after it was paused.
Use this method if already using MWBcloseScannerOnDecode(false) to achieve continuous scanning.
Scan a single frame.
Either an ImageData object or a dataURL image string to be scanned.
Using ImageData is convenient and faster because data is already in desired format, the only requirement is that the data remains unchanged during the scan (i.e. until it's copied to memory).
Using dataURL is slower and not recommended for live scanning scenarios. Because the actual data is represented in base64 in a respective encoding/compressing format (png, jpeg, etc.), it requires extra decoding steps to get the raw pixel format, which takes significant time.
Result callback (will get replaced by a default callback if it's missing)
Scan an image file.
The path to the image file.
Result callback (will get replaced by a default callback if it's missing)
Set the visibility of the cameraPreview blinking lines.
An API version of the MWBsetBlinkingLineVisible configuration method.
Visible blinking lines. Default value is true.
Set a custom callback function that's called once the scan is performed. Should be called in the configuration stage.
Note: If the scanning method provides its own callback, the provided callback will be used.
Result callback to set as a default callback.
Set a specific camera to use for this device.
Note: Overrides the effect of the MWBuseFrontCamera setting.
Unique id of the camera (obtained from getCameras).
Set the license image file. Should be called in the configuration stage.
Note: When setting just the image file name, the image file is expected to be in the same directory as the .html file which includes the .js file which calls the setIcon method (even when the .js file resides in a different directory). Relative paths work relative to the directory of the including .html file. Absolute paths work with respect to the root.
Note: Since v1.1.0 this method must be called. The licensing image can be an empty file (i.e. carries no license) but still must be used.
The license image name (and path if different directory is used).
Allows cross origin if set to true, otherwise if set to false or not used at all it keeps the default (no cross origin).
Allowing cross origin would enable the option of using a license image that is hosted on another server i.e. originates from a domain other than the one the web app is hosted on, such as a CDN for example.
Note: The server hosting the licensing image also needs to be configured to allow CORS for it.
An API version of the MWBsetOverlayMode configuration method.
The overlay mode of the cameraPreview overlay.
Starts the scanner with different params.
Fullscreen scanner:
mwbScanner.startScanning()
mwbScanner.startScanning(callback)
Partial view scanner:
mwbScanner.startScanning(x, y, width, height)
mwbScanner.startScanning(callback, x, y, width, height)
Container element:
<div id="cmbweb-preview-container" style="border:1px solid; position:fixed; top:25%; left:25%; width:50%; height:30%; background-color:gray;"></div>
If a div element with "cmbweb-preview-container" id is used in the html page, the sdk will detect this and operate in 'container mode' (the cameraPreview will fill the container).
The x,y,width,height args have no effect in container mode.
⚡ A "cameraReady" event is triggered when the camera is fully initialized after calling the startScanning method. After this event the cameraPreview is shown. See the example event listener.
Calling the startScanning method involves camera access and requests user permissions if needed.
Depending on device features and user permissions for camera access, any of the following camera-related errors could be returned in the result.errorDetails.name of the callback:
See result fields.
Result callback (will get replaced by a default callback if it's missing)
Partial view left edge (percentage)
Partial view top edge (percentage)
Partial view witdh (percentage)
Partial view height (percentage)
Toggles the flash feature (if present) of the camera.
The toggle switches between on and off state.
Toggles between pause and resume of scanning.
The camera stream will continue running (i.e. will be shown on the cameraPreview), but no frames will be scanned by the decoder during the paused state. This will significantly reduce CPU usage.
Toggles the zoom feature (if present) of the camera.
Typically there are 3 zoom states that the toggle cycles through: no zoom, 50% zoom, 100% zoom.
Generated using TypeDoc
The following interface describes the mwbScanner object.
The mwbScanner object is the main object which exposes the cmbWeb API.
⚡ A "scannerModuleLoaded" event is triggered once all the modules have loaded after loading the page. After this event the scanner is ready and exposed methods from the mwbScanner object can be invoked.
Listen for this event before using the API methods from the mwbScanner object. See the example event listener.