×
MENU
@ViewData["CurrentPage"]
Table of contents

Thanks for downloading Dynamsoft Barcode Reader Package!

Your download will start shortly. If your download does not begin, click here to retry.

JavaScript API Reference - BarcodeScanner Initialize and Destroy Methods

  • Class Methods
Method Description
createInstance Create a BarcodeScanner object.
detectEnvironment Detect the current environment. Inherited from the BarcodeReader class.
isLoaded Check if the decoding module is loaded. Inherited from the BarcodeReader class.
loadWasm Manually load and compile the decoding WASM module. Inherited from the BarcodeReader class.
  • Instance Method
Method Description
destroy Destroy the BarcodeScanner object.
getUIElement Get HTML element containing the BarcodeScanner object.
setUIElement Set HTML element containing the BarcodeScanner object.

createInstance

Create a BarcodeScanner object. Overrides BarcodeReader.createInstance.

createInstance() returns Promise

Return Value

Promise<BarcodeScanner>

Sample

let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();

destroy

Destroy the BarcodeScanner object. Equivalent to the previous method deleteInstance(). Overrides BarcodeReader.destroy.

destroy() returns Promise

Return Value

Promise<any>

getUIElement

Get the HTML element containing the BarcodeScanner object.

getUIElement() returns HTMLElement

Return Value

HTMLElement

setUIElement

Set HTML element containing the BarcodeScanner object. In v8.0, setUIElement can be used to set an existing video stream element. The video element of the existing video stream must specify dbrScanner-existingVideo className.

setUIElement(elementOrUrl) returns Promise

Parameters

elementOrUrl: HTMLElement | string;

Return Value

Promise<void>

Sample

<video class="dbrScanner-video" playsinline="true"></video>
<script>
    let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
    scanner.setUIElement(document.getElementsByClassName("dbrScanner-video")[0]);
    await scanner.show();
</script>

:+1: Tips and Tricks

  • This API changes the UI on the fly. If you want the UI to change as soon as the camera is created, use defaultUIElementURL instead.

This page is compatible for:

Version 7.5

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest Version
  • version 8.0
  • version 7.6
  • version 7.5
Change +
© 2003–2020 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support