MENU
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

Method Description
createInstance Create a BarcodeScanner object.
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(config) returns Promise

Parameters

configoptional any

Return Value

Promise<BarcodeScanner>

test

Sample

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

Read barcodes from live camera

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

Sample

Read barcodes from live camera

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>

Read barcodes from live camera

:+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 7.6
  • version 7.5
Change +
© 2003–2020 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support