On this page

Stuck? Open a support ticket and the barKoder team will help. Open a ticket

API reference

Every method, setting, enum and result of the barKoder Web SDK, grouped by what you do with it.

Initialize the BarkoderSDK. This function must always be called first and returns a promise, which if resolved successfully, provides the Barkoder object.

JavaScript
initialize(license: string, options?: { maxThreads?: number, wasmPath?: string, obtainVersionedBinary?: boolean, useMainThreadOnly?: boolean, canvasPreview?: boolean }): Promise<Barkoder>
  • license - the licensing key
  • options - an optional object for configuring SDK initialization properties
    • maxThreads - Configures the desired maximum number of scanning threads. Default value is 2. Supported range is 1 to 4 (if the requested value is not supported by the device, the closest available value will be used)
    • wasmPath - Allows a custom path or filename to be provided for the .wasm binary
    • obtainVersionedBinary - Enables appending the SDK version to the .wasm URL to prevent browser caching issues during update (e.g. barkoder.wasm becomes barkoder.wasm?v=1.7.0). When wasmPath is provided, versioning is applied only if the path ends with .wasm (paths that already contain query parameters, such as barkoder.wasm?v=123, remain unchanged)
    • useMainThreadOnly - Enables the legacy single-threaded scanning mode, which can reduce CPU, battery, and memory usage, and is recommended when single-threaded performance is sufficient i.e. multithreaded performance is not required
    • canvasPreview - enable/disable showing the camera stream to canvas instead of a video element (by default its enabled only for iOS devices)

The initialize method must be called first. After it completes, it returns an object with the following members:

Scanning & session #

startScanner #

JavaScript
startScanner(resultCallback?: function): number

Starts the scanner. This will access and start the camera, creates a preview to show the stream and adds it to a container element, and decode frames from it.

JavaScript
startScanner: (resultCallback?: (result: Result) => void) => number

stopScanner #

JavaScript
stopScanner()

Stops a previously started scanning session by startScanner.

JavaScript
stopScanner: () => void

scanFrame #

Scans a single frame (as ImageData or dataURL).

JavaScript
scanFrame: (imageData: ImageData | string, resultCallback?: (result: Result) => void) => void | Promise<BKResult>;

setPauseDecoding #

TypeScript
setPauseDecoding(pause: boolean)

Pause the decoding.

TypeScript
setPauseDecoding: (pause: boolean) => void

setCloseEnabled #

TypeScript
setCloseEnabled(closeEnabled: boolean): number

Enable or disable close button on camera preview. Default is enabled.

TypeScript
setCloseEnabled: (closeEnabled: boolean) => number

setContinuous #

TypeScript
setContinuous(continuous: boolean): number

Enable or disable continuous scanning. Default is disabled.

TypeScript
setContinuous: (continuous: boolean) => number

setScannerTimeout #

TypeScript
setScannerTimeout(timeout: number)

Set the desired timeout in seconds.

This setting affects how long the scanner will run i.e. the camera preview will be open, the camera stream will run, and the decoder will actively scan for barcodes. Note that in mobile devices scanning for a longer period of time can result in higher heat output and battery drain.

The timeout to apply. Default value is 60. Accepts values in the range of 10-3600. Accepts 0 to disable the timeout.

TypeScript
setScannerTimeout: (timeout: number) => number

setDpsLimit #

Set the desired decodes per second limit.

This setting affects how often the scanner will try to decode a frame. Higher values increase the likelihood of barcodes being detected faster, but is also more demanding on the device.

The DPS limit to apply. Default value is 28. Accepts values in the range of 1-30.

JavaScript
setDpsLimit: ((dpsLimit) => number)

applyTemplate #

TypeScript
applyTemplate(templateFile: string, templateMode: string)

Apply a set of pre-defined settings from a file.The template file in json format, containing settings for different template modes.

TypeScript
applyTemplate: (templateFile: string, templateMode: string) => void

setDecodingSpeed #

Set the pace and effort at which the scanner will try to decode barcodes.The decoding speed to apply. Default is Normal.

JavaScript
setDecodingSpeed: ((decodingSpeed) => number)

getVersion #

TypeScript
getVersion(): { barkoderWebVersion: string, barkoderVersion: string, barkoderFullVersion: string }

Get the BarkoderSDK version details.

TypeScript
getVersion: () => { barkoderWebVersion: string ; barkoderVersion: string ; barkoderFullVersion: string }

In OCR only:

TypeScript
getVersion: () => { barkoderWebVersion: string, barkoderVersion: string, barkoderFullVersion: string, barkoderOcrVersion: boolean };

getDecodingSpeed #

JavaScript
getDecodingSpeed(): number

Get the decoding speed.

JavaScript
getDecodingSpeed: () => DecodingSpeed

getHeaderHeight #

JavaScript
getHeaderHeight: () => number;

Returns the current height of the AR header.

getLocationTransitionSpeed #

JavaScript
getLocationTransitionSpeed: () => number;

Returns the animation speed used for barcode location transitions in AR mode.

getDoubleTapToFreezeEnabled #

JavaScript
getDoubleTapToFreezeEnabled: () => boolean;

Returns whether double-tap to freeze the camera preview is enabled.

getHeaderShowMode #

JavaScript
getHeaderShowMode: () => number;

Returns the current AR header show mode.

getLocationType #

JavaScript
getLocationType: () => number;

Returns the currently configured AR location visualization type.

getHeaderTextColorSelected #

JavaScript
getHeaderTextColorSelected: () => string;

Returns the text color used for selected AR headers.

getHeaderTextColorNonSelected #

JavaScript
getHeaderTextColorNonSelected: () => string;

Returns the text color used for non-selected AR headers.

setLineScanAnimationMode #

TypeScript
setLineScanAnimationMode: (animationMode: number) => void;

Sets the animation mode which controls how the center line on the camera preview will be animated while using the LineScan functionality ("single_line_scan" customOption).

setHeaderHeight #

TypeScript
setHeaderHeight: (height: number) => void;

Sets the height of the AR header displayed above detected barcode locations.

setLocationTransitionSpeed #

TypeScript
setLocationTransitionSpeed: (transitionSpeed: number) => void;

Sets the animation speed used when barcode locations transition in AR mode.

setDoubleTapToFreezeEnabled #

TypeScript
setDoubleTapToFreezeEnabled: (enabled: boolean) => void;

Enables or disables freezing the camera preview when the user double-taps the screen in AR mode.

setHeaderShowMode #

JavaScript
setHeaderShowMode: (headerShowMode: BarkoderARHeaderShowMode) => void;

Controls when and how the AR header is displayed.

setLocationType #

JavaScript
setLocationType: (locationType: BarkoderARLocationType) => void;

Sets the type of location visualization used for detected barcodes in AR mode.

setHeaderTextColorSelected #

TypeScript
setHeaderTextColorSelected: (color: string) => void;

Sets the text color of the AR header when the associated barcode location is selected.

setHeaderTextColorNonSelected #

TypeScript
setHeaderTextColorNonSelected: (color: string) => void;

Sets the text color of the AR header when the associated barcode location is not selected.

getLineScanAnimationMode #

JavaScript
getLineScanAnimationMode: () => number;

Retrieves the animation mode used for the center line on the camera preview while using the LineScan functionality.

setLineScanColor #

TypeScript
setLineScanColor: (color: string) => void;

Sets the color of the center line on the camera preview while using the LineScan functionality ("single_line_scan" customOption).

getLineScanColor #

JavaScript
getLineScanColor: () => string;

Retrieves the color of the center line on the camera preview while using the LineScan functionality.

setLineScanWidth #

TypeScript
setLineScanWidth: (width: number) => void;

Sets the width of the center line on the camera preview while using the LineScan functionality ("single_line_scan" customOption).

getLineScanWidth #

JavaScript
getLineScanWidth: () => number;

Retrieves the width of the center line on the camera preview while using the LineScan functionality.

getDecodingSpeed #

JavaScript
getDecodingSpeed: (() => DecodingSpeed)

Get the decoding speed.

configureBarkoder #

JavaScript
configureBarkoder: ((barkoderConfig) => boolean)

Configure the barkoder scanner with a defined model of settings.

Example:

JavaScript
let cfg = new Barkoder.configTypes.BarkoderConfig({
    closeSessionOnResultEnabled: true,
    barkoderResolution: Barkoder.constants.CameraResolution.HD,
    decoder: new Barkoder.configTypes.DekoderConfig({
        qr: new Barkoder.configTypes.BarcodeConfig({enabled: true}),
        ean8: new Barkoder.configTypes.BarcodeConfig({enabled: true}),
        pdf417: new Barkoder.configTypes.BarcodeConfig({enabled: true}),
        general: new Barkoder.configTypes.GeneralSettings({
            decodingSpeed: Barkoder.constants.DecodingSpeed.Normal
        })
    })
});

Barkoder.configureBarkoder(cfg);

scanFromLocalFileSystem #

JavaScript
scanFromLocalFileSystem: ((input, resultCallback?) => void)

Scans a file from an input element of type file.

Example usage:

XML
<form><input type="file" value="Scan file" 
onchange="Barkoder.scanFromLocalFileSystem(this)"/></form>

getContinuous #

JavaScript
getContinuous: () => boolean;

Get the continuous scanning state.

Camera #

setCameraResolution #

TypeScript
setCameraResolution(cameraResolution: number)

Set the desired camera resolution.

Note that if device is not capable of providing the exact resolution, the closest available one will be used.

JavaScript
setCameraResolution: (cameraResolution: CameraResolution) => number

getCameras #

Get all available cameras from the device.

Note that this method may prompt the user for camera access permissions, if they are not already granted.

JavaScript
getCameras: () => Promise<Cameras>

setCameraId #

TypeScript
setCameraId(cameraId: string)

Set the desired camera to use.The camera id previously obtained from getCameras.

TypeScript
setCameraId: (cameraId: string) => void

setFlashEnabled #

TypeScript
setFlashEnabled(flashEnabled: boolean): number

Enable or disable flash button on camera preview. Default is enabled.

TypeScript
setFlashEnabled: (flashEnabled: boolean) => number

setZoomEnabled #

TypeScript
setZoomEnabled(zoomEnabled: boolean): number

Enable or disable zoom button on camera preview. Default is enabled.

TypeScript
setZoomEnabled: (zoomEnabled: boolean) => number

setCameraPickerEnabled #

TypeScript
setCameraPickerEnabled(cameraPickerEnabled: boolean): number

Enable or disable cameraPicker button on camera preview. Default is enabled.

TypeScript
setCameraPickerEnabled: (cameraPickerEnabled: boolean) => number

changeFlashState #

JavaScript
changeFlashState()

Change i.e. toggle the current flash state.

Should be used only during an active scanning session. Outside of one, there is no effect.

JavaScript
changeFlashState: () => void

changeZoomState #

JavaScript
changeZoomState()

Change i.e. cycle through the current zoom state.

Should be used only during an active scanning session. Outside of one, there is no effect.

JavaScript
 changeZoomState: () => void

setTargetZoom #

Sets an initial zoom level to target (if available). Typical values are between 1 and 4.

TypeScript
 setTargetZoom: (targetZoom: number) => void;

getTargetZoom #

Retrieves the initial targetted zoom level.

JavaScript
 getTargetZoom: () => number;

isLocationInPreviewEnabled #

JavaScript
isLocationInPreviewEnabled: () => boolean

Check if the location in the preview is enabled.

setLocationInPreviewEnabled #

JavaScript
setLocationInPreviewEnabled: ((enabled) => void)

Enables or disables the display of barcode location information on the camera preview.

getCameraResolution #

JavaScript
getCameraResolution: () => number;

Retrieves the resolution for barcode scanning.

getActiveCamera #

JavaScript
getActiveCamera: () => string | null;

Get a used camera. It should be used only during an active scanning session. Outside of one, it returns null.

getMaxZoomFactor #

JavaScript
getMaxZoomFactor: () => number;

Retrieves the maximum available zoom factor for the device's camera.

isFlashAvailable #

JavaScript
isFlashAvailable: () => boolean;

Checks whether the device has a built-in flash (torch) that can be used for illumination during barcode scanning.

Barcode types #

setLengthRange #

TypeScript
setLengthRange(decoder: number, minimumLength: number, maximumLength: number)

Set the minimum and maximum length to be detected.

TypeScript
setLengthRange: (decoder: Decoders, minimumLength: number, maximumLength: number) => number

setCode11ChecksumType #

TypeScript
setCode11ChecksumType(code11ChecksumType: number): number

Set checksum type for Code 11.

TypeScript
setCode11ChecksumType: (code11ChecksumType: number) => number

setCode39ChecksumType #

TypeScript
setCode39ChecksumType(code39ChecksumType: number): number

Set checksum type for Code 39.

TypeScript
setCode39hecksumType: (code39ChecksumType: number) => number

setMsiChecksumType #

TypeScript
setMsiChecksumType(msiChecksumType: number): number

Set checksum type for MSI.

TypeScript
setMsiChecksumType: (msiChecksumType: number) => number

setDatamatrixDpmModeEnabled #

TypeScript
setDatamatrixDpmModeEnabled(dpmModeEnabled: boolean): number

Enable Datamatrix dpm mode.

TypeScript
setDatamatrixDpmModeEnabled: (dpmModeEnabled: boolean) => number

setEncodingCharacterSet #

TypeScript
setEncodingCharacterSet(encodingCharacterSet: number)

Set the character set to be used for encoding the results.

TypeScript
setEncodingCharacterSet: (encodingCharacterSet: number) => void

setEnabledDecoders #

TypeScript
setEnabledDecoders(...args: number)

Set the decoders to enable.

Note that this method uses a rest parameter i.e. accepts an indefinite number of arguments.

JavaScript
setEnabledDecoders: (...decoders: Decoders[]) => void

setCustomOption #

Sets a custom decoder option by key.

See more details about available options and their values.

TypeScript
setCustomOption: (customOption: string, value: number) => number;

setFormatting #

Set the type of formatting to apply to results.Default is Disabled.

JavaScript
setFormatting: (formatting: Formatting) => number

setEnableVINRestrictions #

TypeScript
setEnableVINRestrictions(enableVINRestrictions: number)

Enable or disable VIN restrictions. Default is Disabled.

TypeScript
setEnableVINRestrictions: (enableVINRestrictions: number) => number

setUpcEanDeblur #

TypeScript
setUpcEanDeblur: (deblur: number) => number

Description: Enable or disable deblur. Default is Disabled.

setEnableMisshaped1D #

TypeScript
setEnableMisshaped1D(enableMisshaped1D: number)

Enable detection of misshaped 1D barcodes.

TypeScript
setEnableMisshaped1D: (enableMisshaped1D: number) => number

getUpcEanDeblur #

JavaScript
getUpcEanDeblur(): number

Get the UPC/EAN deblur state.

JavaScript
getUpcEanDeblur: () => number

getEnableVINRestrictions #

JavaScript
getEnableVINRestrictions(): number

Get the VIN restrictions state.

JavaScript
getEnableVINRestrictions: () => number

getEnableMisshaped1D #

JavaScript
getEnableMisshaped1D(): number

Get the misshaped 1D state.

JavaScript
getEnableMisshaped1D: () => number

getEncodingCharacterSet #

JavaScript
getEncodingCharacterSet: () => number;

Retrieves the character set used for encoding barcode data.

getFormatting #

JavaScript
getFormatting: () => number

Retrieves the formatting type used for presenting decoded barcode data.

getMsiChecksumType #

JavaScript
getMsiChecksumType: () => number;

Retrieves the MSI checksum type.

getCode11ChecksumType #

JavaScript
getCode11ChecksumType: () => number;

Retrieves the Code11 checksum type

getCode39ChecksumType #

JavaScript
getCode39ChecksumType: () => number;

Retrieves the checksum type for Code 39 barcodes

isBarcodeTypeEnabled #

TypeScript
isBarcodeTypeEnabled: (decoder: number) => boolean | -1

Checks if a specific barcode type is enabled

setBarcodeTypeEnabled #

TypeScript
setBarcodeTypeEnabled: (decoder: number, enable: boolean) => number;

Sets a specific barcode type to be enabled

getBarcodeTypeLengthRange #

TypeScript
getBarcodeTypeLengthRange: (decoder: number) => [number, number] | -1;

Retrieves the length range of a specific barcode type

setQRDpmModeEnabled #

TypeScript
setQRDpmModeEnabled: (dpmModeEnabled: boolean) => number;

Sets whether the Direct Part Marking (DPM) mode for QR barcodes is enabled.

setQRMicroDpmModeEnabled #

TypeScript
setQRMicroDpmModeEnabled: (dpmModeEnabled: boolean) => number;

Sets whether the Direct Part Marking (DPM) mode for QRMicro barcodes is enabled.

getDatamatrixDpmModeEnabled #

TypeScript
setDatamatrixDpmModeEnabled: (dpmModeEnabled: boolean) => number;

Retrieves whether the Direct Part Marking (DPM) mode for Datamatrix barcodes is enabled.

setEnableComposite #

JavaScript
setEnableComposite: (enableComposite: EnableComposite) => number;

Sets whether GS1 Composite Barcodes is enabled.

getEnableComposite #

JavaScript
getEnableComposite: () => number;

Retrieves whether GS1 Composite Barcodes is enabled.

getEnabledDecoders #

JavaScript
getEnabledDecoders: () => number[];

Retrieves an array of enabled decoders.

Results #

scanImage #

TypeScript
scanImage(imageUri: string, resultCallback?: function)

Scans a single image.

JavaScript
scanImage: (imageUri: string, resultCallback?: (result: Result) => void) => void | Promise<Result>

getSADLImage #

Helper method for handling SADL image from SADL-parsed JSON string.

JavaScript
getSADLImage: (jsonString: string) => Promise<ImageData>;

setMulticodeCachingEnabled #

TypeScript
setMulticodeCachingEnabled(multicodeCachingEnabled: number)

Enable or disable multicode caching. Default is Disabled.

TypeScript
setMulticodeCachingEnabled: (multicodeCachingEnabled: number) => number

setMulticodeCachingDuration #

TypeScript
setMulticodeCachingDuration(multicodeCachingDuration: number)

Set the duration for multicode caching.The duration in ms.

TypeScript
setMulticodeCachingDuration: (multicodeCachingDuration: number) => number

setDuplicatesDelayMs #

TypeScript
setDuplicatesDelayMs(duplicatesDelayMs: number)

Set the delay for duplicate results.

TypeScript
setDuplicatesDelayMs: (duplicatesDelayMs: number) => number

Supports setting a positive integer as delay in milliseconds, 0 for no delay, and -1 for no duplicates indefinitely.

getResultDisappearanceDelayMs #

JavaScript
getResultDisappearanceDelayMs: () => number;

Returns the delay (in milliseconds) before detected results disappear from the AR view.

isImageResultEnabled #

JavaScript
isImageResultEnabled: () => boolean

Checks if the inclusion of the captured frame in the result is enabled.

setImageResultEnabled #

JavaScript
setImageResultEnabled: ((enabled) => void)

Enables or disables the capturing and processing of image data when a barcode is successfully detected.

setResultDisappearanceDelayMs #

TypeScript
setResultDisappearanceDelayMs: (disappearanceDelayMs: number) => void;

Sets the delay (in milliseconds) after which detected barcode results disappear from the AR view.

setMaximumResultsCount #

JavaScript
setMaximumResultsCount: ((maximumResultsCount) => number)

Set the maximum amount of results to be detected from a single frame or image. It cannot change maximumResultCount if AR mode is used.

getMaximumResultsCount #

JavaScript
getMaximumResultsCount: (() => number)

Get the maximum results count.

getDuplicatesDelayMs #

JavaScript
getDuplicatesDelayMs: (() => number)

Get the duplicates delay.

setBeepOnSuccessEnabled #

TypeScript
setBeepOnSuccessEnabled: (beepEnabled: boolean) => number;

Enables or disables the audible beep sound upon successfully decoding a barcode.

isBeepOnSuccessEnabled #

JavaScript
isBeepOnSuccessEnabled: () => boolean;

Retrieves the value indicating whether a beep sound is played on successful barcode scanning.

getMulticodeCachingEnabled #

JavaScript
getMulticodeCachingEnabled: () => number;

Retrieves whether multi-code caching is enabled

getMulticodeCachingDuration #

JavaScript
getMulticodeCachingDuration: () => number;

Retrieves the caching duration (in milliseconds) for multi-code results

setBarcodeThumbnailOnResultEnabled #

TypeScript
setBarcodeThumbnailOnResultEnabled: (enabled: boolean) => void;

Sets whether to enable barcode thumbnail on result.

isBarcodeThumbnailOnResultEnabled #

JavaScript
isBarcodeThumbnailOnResultEnabled: () => boolean;

Checks if the barcode thumbnail on the result is enabled.

Region & overlay #

setRegionOfInterest #

TypeScript
setRegionOfInterest(left: number, top: number, width: number, height: number)

Set the desired region of interested. The decoder will only look at this area for barcodes.

TypeScript
setRegionOfInterest: (left: number, top: number, width: number, height: number) => void
NameTypeDescription
leftnumberPercentage of the starting point on the x-axis of the preview.
topnumberPercentage of the starting point on the y-axis of the preview.
widthnumberPercentage of the width of the preview.
heightnumberPercentage of the height of the preview.

getRegionOfInterest #

TypeScript
getRegionOfInterest(): { x:number, y:number, width: number, height: number }

Note that these values may be different during active scanning than the ones set by setRegionOfInterest.

Get the currently used region of interest.

TypeScript
getRegionOfInterest: () => { x: number ; y: number ; width: number ; height: number }

getLocationLineColor #

JavaScript
getLocationLineColor: () => string

Retrieves the color code representing the line color used to indicate the location of detected barcodes.

getLocationLineWidth #

JavaScript
getLocationLineWidth: () => number

Retrieves the current width setting for the lines indicating the location of detected barcodes on the camera feed.

getSelectedLocationColor #

JavaScript
getSelectedLocationColor: () => string;

Returns the color currently used for the selected barcode location outline in AR mode.

getNonSelectedLocationLineColor #

JavaScript
getNonSelectedLocationLineColor: () => string;

Returns the color currently used for non-selected barcode location outlines in AR mode.

getSelectedLocationLineWidth #

JavaScript
getSelectedLocationLineWidth: () => number;

Returns the line width used for the selected barcode location outline in AR mode.

getNonSelectedLocationLineWidth #

JavaScript
getNonSelectedLocationLineWidth: () => number;

Returns the line width used for non-selected barcode location outlines in AR mode.

getRoiLineColor #

JavaScript
getRoiLineColor: () => string

Retrieves the color code representing the line color of the Region of Interest (ROI) on the camera preview.

getRoiLineWidth #

JavaScript
getRoiLineWidth: () => number

Retrieves the current width setting for the lines outlining the Region of Interest (ROI) on the camera preview.

isRegionOfInterestVisible #

JavaScript
isRegionOfInterestVisible: () => boolean

Checks if the region of interest (ROI) is visible.

setRoiLineColor #

JavaScript
setRoiLineColor: ((color) => void)

Sets the color of the lines outlining the Region of Interest (ROI) for barcode scanning on the camera feed.

setRoiLineWidth #

JavaScript
setRoiLineWidth:((width) => void)

Sets the width of the lines outlining the Region of Interest (ROI) for barcode scanning on the camera feed.

setRegionOfInterestVisible #

JavaScript
setRegionOfInterestVisible: ((visible) => void)

Sets the visibility of the Region of Interest (ROI) on the camera preview

setLocationLineWidth #

JavaScript
setLocationLineWidth: ((width) => void)

Sets the width of the lines indicating the location of detected barcodes on the camera feed.

setLocationLineColor #

JavaScript
setLocationLineColor: ((color) => void)

Sets the color of the lines used to indicate the location of detected barcodes on the camera feed.

setRoiCenterMark #

TypeScript
setRoiCenterMark: (centerMark: number) => void;

Sets the type of mark to be placed in the center of the ROI.

getRoiCenterMark #

JavaScript
getRoiCenterMark: () => number;

Retrieves the type of center mark used.

setSelectedLocationColor #

TypeScript
setSelectedLocationColor: (color: string) => void;

Sets the color used to draw the outline of the currently selected barcode location in AR mode.

setNonSelectedLocationLineColor #

TypeScript
setNonSelectedLocationLineColor: (color: string) => void;

Sets the color used to draw the outline of non-selected barcode locations in AR mode.

setSelectedLocationLineWidth #

TypeScript
setSelectedLocationLineWidth: (width: number) => void;

Sets the line width used for rendering the outline of the selected barcode location in AR mode.

setNonSelectedLocationLineWidth #

TypeScript
setNonSelectedLocationLineWidth: (width: number) => void;

Sets the line width used for rendering the outlines of non-selected barcode locations in AR mode.

setRoiOverlayBackgroundColor #

TypeScript
setRoiOverlayBackgroundColor: (color: string) => void;

Sets the background color of the overlay within the Region of Interest (ROI) for barcode scanning on the camera feed.

setLocationInImageResultEnabled #

TypeScript
setLocationInImageResultEnabled: (enabled: boolean) => void;

Enables or disables the inclusion of barcode location information within the image data result.

getRoiOverlayBackgroundColor #

JavaScript
getRoiOverlayBackgroundColor: () => string;

Retrieves the color code representing the background color of the overlay within the Region of Interest (ROI) on the camera preview.

isLocationInImageResultEnabled #

JavaScript
isLocationInImageResultEnabled: () => boolean;

Retrieves whether the inclusion of barcode location information within the image data result is enabled.

AR mode #

getARMode #

JavaScript
getARMode: () => number;

Returns the currently configured AR mode.

setARMode #

JavaScript
setARMode: (arMode: BarkoderARMode) => void;

Sets the AR mode used for barcode detection and visualization.

Result models #

The result object passed into the result callback method of the startScanner and scanImage methods, or alternatively returned by the scanImage method via Promise, has the following structure:

TypeScript
export declare interface BKResult {
	
	error?: {
		name: string,
		message: string
	};
	
	resultsCount: number;
	barcodeTypeName?: string;
	textualData?: string;
	binaryData?: number[];
	gs1?: number;
	location?: {
		p1: { x:number, y:number },
		p2: { x:number, y:number },
		p3: { x:number, y:number },
		p4: { x:number, y:number }
	};
	capturedFrame?: ImageData,
	capturedBarcode?: ImageData,
	formattedJSON?: string;
	formattedText?: string;
	
	results?: {
		barcodeTypeName: string,
		textualData: string,
		binaryData: number[],
		gs1: number,
		location: {
			p1: { x:number, y:number },
			p2: { x:number, y:number },
			p3: { x:number, y:number },
			p4: { x:number, y:number }
		},
		capturedFrame?: ImageData,
		capturedBarcode?: ImageData,
		formattedJSON?: string;
		formattedText?: string;
	}[];
}

errorThe error information. This field is present only when an error occurs after a startScanner call, or alternatively after a scanImage call if no decoders/symbologies are enabled.
resultsCountThe amount of results. If larger than 1, each result will be present in the results array.
barcodeTypeNameThe name of the barcode type.
textualDataThe result as text. Note that without adequate formatting, certain characters cannot be shown (e.g. non-printable characters). Refer to binaryData, or alternatively to formattedJSON / formattedText.
binaryDataThe result as an array of bytes.
gs1The result is GS1 compliant.
locationThe location of the result in the frame/image.
capturedFrameThe frame where a barcode was detected. The presense of this field is controlled via setImageResultEnabled
capturedBarcodeThe barcode area of the frame. The presense of this field is controlled via setBarcodeThumbnailOnResultEnabled
formattedJSONJSON string containing all parsed data. The presense of this field depends on used Formatting i.e. setFormatting and if raw result is parsable. The string can then be passed onto JSON.parse to obtain JS objects.
formattedTextKey/value pairs of parsed data. The presense of this field depends on used Formatting i.e. setFormatting and if raw result is parsable.
resultsAn array of result objects, each having the already listed properties (barcodeTypeName, textualData, binaryData, gs1, location, capturedFrame, capturedBarcode, formattedJSON, formattedText) as described above.


Callbacks & events #

startScanner #

Description: Fires after a startScanner() call, when the first frame from the camera is received

Example:

JavaScript
Barkoder.addEventListener("startScanner", function(e) {
		console.log(e.detail); //Prints "Camera started."
	});

stopScanner #

Description: Fires after a stopScanner() call, when the camera is stopped and the camera preview is removed.

Example:

JavaScript
Barkoder.addEventListener("stopScanner", function(e) {
		console.log(e.detail); //Prints "Camera stopped."
	});

scannerTimeout #

Description: Fires after a startScanner() call, when the scanner timeout runs out if the scanning session is not closed by other means (i.e. successfully scanning a barcode in non-continuous mode, calling stopScanner(), etc.), and there is a non-zero timeout value (set via setScannerTimeout method)

Example:

JavaScript
Barkoder.addEventListener("scannerTimeout", function(e) {
		console.log(e.detail); //Prints "Scanner timed out."
	});

Enums #

DecodingSpeed #

This setting determines the pace at which the system processes and decodes barcode information, affecting the speed of barcode scanning.

  • Fast: 0 - Scanner will spend less time on decoding. While this if faster, it may not detect more demanding barcodes.
  • Normal: 1 - Default. Scanner holds a balance between how long decoding takes, and the success rate of detecting barcodes.
  • Slow: 2 - Scanner will spend more time on decoding. While this is slower, it may detect very demanding barcodes that cannot be read otherwise.
  • Rigorous: 3 - Scanner will spend the most time on decoding. This is quite demanding on the device hardware - it may find more results, but will also take longer to do so. It is only recommended when scanning from an image.

Example:

JavaScript
Barkoder.setDecodingSpeed(Barkoder.constants.DecodingSpeed.Slow);

Decoders #

Supported decoders (barcode types).

JavaScript
Barkoder.constants.Decoders.Aztec               //: 0,
Barkoder.constants.Decoders.AztecCompact        //: 1,
Barkoder.constants.Decoders.QR                  //: 2,
Barkoder.constants.Decoders.QRMicro             //: 3,
Barkoder.constants.Decoders.Code128             //: 4,
Barkoder.constants.Decoders.Code93              //: 5,
Barkoder.constants.Decoders.Code39              //: 6,
Barkoder.constants.Decoders.Codabar             //: 7,
Barkoder.constants.Decoders.Code11              //: 8,
Barkoder.constants.Decoders.Msi                 //: 9,
Barkoder.constants.Decoders.UpcA                //: 10,
Barkoder.constants.Decoders.UpcE                //: 11,
Barkoder.constants.Decoders.UpcE1               //: 12,
Barkoder.constants.Decoders.Ean13               //: 13,
Barkoder.constants.Decoders.Ean8                //: 14,
Barkoder.constants.Decoders.PDF417              //: 15,
Barkoder.constants.Decoders.PDF417Micro         //: 16,
Barkoder.constants.Decoders.Datamatrix          //: 17,
Barkoder.constants.Decoders.Code25              //: 18,
Barkoder.constants.Decoders.Interleaved25       //: 19,
Barkoder.constants.Decoders.ITF14               //: 20,
Barkoder.constants.Decoders.IATA25              //: 21,
Barkoder.constants.Decoders.Matrix25            //: 22,
Barkoder.constants.Decoders.Datalogic25         //: 23,
Barkoder.constants.Decoders.COOP25              //: 24,
Barkoder.constants.Decoders.Code32              //: 25,
Barkoder.constants.Decoders.Telepen             //: 26,
Barkoder.constants.Decoders.Dotcode             //: 27,
Barkoder.constants.Decoders.Databar14           //: 29,
Barkoder.constants.Decoders.DatabarLimited      //: 30,
Barkoder.constants.Decoders.DatabarExpanded     //: 31,
Barkoder.constants.Decoders.PostalIMB           //: 32,
Barkoder.constants.Decoders.Postnet             //: 33,
Barkoder.constants.Decoders.Planet              //: 34,
Barkoder.constants.Decoders.AustralianPost      //: 35,
Barkoder.constants.Decoders.RoyalMail           //: 36,
Barkoder.constants.Decoders.KIX                 //: 37,
Barkoder.constants.Decoders.JapanesePost        //: 38,
Barkoder.constants.Decoders.MaxiCode            //: 39

In OCR only, in addition to above:

JavaScript
Barkoder.constants.Decoders.IDDocument             //: 28

Example:

JavaScript
Barkoder.setEnabledDecoders(
	Barkoder.constants.Decoders.QR,
	Barkoder.constants.Decoders.Ean8,
	Barkoder.constants.Decoders.PDF417
);

Code11ChecksumType #

  • disabled: 0
  • single: 1
  • double: 2

Example:

JavaScript
Barkoder.setCode11ChecksumType(Barkoder.constants.Code11ChecksumType.single);

Code39ChecksumType #

  • disabled: 0
  • enabled: 1

Example:

JavaScript
Barkoder.setCode39ChecksumType(Barkoder.constants.Code39ChecksumType.enabled);

MsiChecksumType #

  • disabled: 0
  • mod10: 1
  • mod11: 2
  • mod1010: 3
  • mod1110: 4
  • mod11IBM: 5
  • mod1110IBM: 6

Example:

JavaScript
Barkoder.setMsiChecksumType(Barkoder.constants.MsiChecksumType.mod1010);

Formatting #

This setting determines if the decoder should apply a specific formatting to results.

  • Disabled: 0 - Keep the raw result.
  • Automatic: 1 - Detect if result is parsable and apply parsing if so.
  • GS1: 2 - Use GS1 parser.
  • AAMVA: 3 - Use AAMVA parser.
  • SADL: 4 - Use South African Drivers License parser.
  • BCBP: 5 - Use Bar Coded Boarding Pass parser.

Example:

JavaScript
Barkoder.setFormatting(Barkoder.constants.Formatting.AAMVA);

EncodingCharacterSet #

  • None: 0
  • ISO_8859_2: 1
  • ISO_8859_5: 2
  • Shift_JIS: 3
  • US_ASCII: 4
  • UTF_8: 5
  • UTF_16: 6
  • windows_1251: 7
  • windows_1256: 8
  • BINARY: 9

Example:

JavaScript
Barkoder.setEncodingCharacterSet(Barkoder.constants.EncodingCharacterSet.UTF_8);

CameraResolution #

  • HD: 0 - High Definition: 1280x720
  • FHD: 1 - Full HD: 1920x1080

Example:

JavaScript
Barkoder.setCameraResolution(Barkoder.constants.CameraResolution.FHD);

CenterMark #

  • None: 0
  • Crosshair: 1

Example:

JavaScript
Barkoder.setRoiCenterMark(Barkoder.constants.CenterMark.Crosshair);

LineScanAnimationMode #

  • None: 0
  • NormalBlinking: 1
  • FastBlinking: 2

Example:

JavaScript
Barkoder.setLineScanAnimationMode(Barkoder.constants.LineScanAnimationMode.NormalBlinking);

BarkoderARMode #

  • OFF: 0
  • InteractiveDisabled: 1
  • InteractiveEnabled: 2
  • NonInteractive: 3

Example:

JavaScript
Barkoder.setARMode(Barkoder.constants.BarkoderARMode.InteractiveDisabled);

BarkoderARHeaderShowMode #

  • NEVER: 0
  • ALWAYS: 1
  • ONSELECTED: 2

Example:

JavaScript
Barkoder.setHeaderShowMode(Barkoder.constants.BarkoderARHeaderShowMode.ONSELECTED);

BarkoderARLocationType #

  • NONE: 0
  • TIGHT: 1
  • BOUNDINGBOX: 2

Example:

JavaScript
Barkoder.setLocationType(Barkoder.constants.BarkoderARLocationType.BOUNDINGBOX);

EnableComposite #

  • Disable: 0
  • Enable: 1

Example:

JavaScript
Barkoder.setEnableComposite(Barkoder.constants.EnableComposite.Enable);

UpcEanDeblur #

  • Disable: 0
  • Enable: 1

Example:

JavaScript
Barkoder.setUpcEanDeblur(Barkoder.constants.UpcEanDeblur.Enable);

MulticodeCachingEnabled #

  • Disable: 0
  • Enable: 1

Example:

JavaScript
Barkoder.setMulticodeCachingEnabled(Barkoder.constants.MulticodeCachingEnabled.Enable);

EnableMisshaped1D #

  • Disable: 0
  • Enable: 1

Example:

JavaScript
Barkoder.setEnableMisshaped1D(Barkoder.constants.EnableMisshaped1D.Enable);

EnableVINRestrictions #

Disable0
Enable1
JavaScript
Barkoder.setEnableVINRestrictions(Barkoder.constants.EnableVINRestrictions.Enable);