How to Upgrade DBR-JS From v7.x To v9.x
Change your license
Your v7.x license is not compatible with v9.x, you must Contact Dynamsoft Sales Team to acquire a new license key. If you have a subscription license or you have valid maintenance for a perpetual license, the upgrade is free of charge.
Update the version number if you are using a CDN
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.6.42/dist/dbr.js"></script>
If you have deployed the library files to your own server, download the latest version and replace the old files.
Update the API you use for licensing the SDK
In v7.x, you probably licensed the SDK with “data-productKeys” like this:
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@7.x/dist/dbr.js" data-productKeys="PRODUCT-KEYS"></script>
In v9.x, use the API license
instead:
<script>
Dynamsoft.DBR.BarcodeScanner.license = 'YOUR-NEW-LICENSE-KEY';
//...
</script>
Breaking Changes
Namespace change
Use the new namespace Dynamsoft.DBR
in place of just Dynamsoft
. The following shows the equivalent changes for BarcodeScanner
and BarcodeReader
:
Dynamsoft.BarcodeScanner -> Dynamsoft.DBR.BarcodeScanner
Dynamsoft.BarcodeReader -> Dynamsoft.DBR.BarcodeReader
If you are using the library as an ES/CMD module, you don’t need to change your code.Otherwise, you can make a global change from
Dynamsoft
toDynamsoft.DBR
in your code.
API Changes
After changing the namespace, check your code and see if you are using any of the APIs in the first column below. If found, change them to the equivalent shown in the second column:
API Name | Notes |
---|---|
Dynamsoft.DBR.detectEnvironment() |
Use Dynamsoft.DBR.BarcodeReader.detectEnvironment() instead. |
Dynamsoft.DBR.engineResourcePath |
Use Dynamsoft.DBR.BarcodeReader.engineResourcePath instead. |
Dynamsoft.DBR.isLoaded() |
Use Dynamsoft.DBR.BarcodeReader.isWasmLoaded() instead. |
Dynamsoft.DBR.loadWasm() |
Use Dynamsoft.DBR.BarcodeReader.loadWasm() instead. |
Dynamsoft.DBR.productKeys |
Use Dynamsoft.DBR.BarcodeReader.license instead. |
Dynamsoft.DBR.version |
Use Dynamsoft.DBR.BarcodeReader.version instead. |
destroy() |
Use destroyContext() instead. |
bDestroyed |
Use isContextDestroyed() instead. |
onUnduplicatedRead |
Use onUniqueRead instead. |
bPlaySoundOnSuccessfulRead |
Use whenToPlaySoundforSuccessfulRead in ScanSettings instead. |
soundOnSuccessfulRead |
Use soundOnSuccessfullRead in ScanSettings instead. |
bSaveOriCanvas |
Use ifSaveOriginalImageInACanvas instead. |
oriCanvas |
Use getOriginalImageInACanvas() instead. |
deblurLevel
is Deprecated
deblurLevel
has been replaced with deblurModes
.
Check out the code below on how to switch from deblurLevel
to deblurModes
.
let settings = await barcodeScanner.getRuntimeSettings();
//settings.deblurLevel = 9;
settings.deblurModes = ["DM_DIRECT_BINARIZATION",
"DM_THRESHOLD_BINARIZATION",
"DM_GRAY_EQUALIZATION",
"DM_SMOOTHING",
"DM_MORPHING",
"DM_DEEP_ANALYSIS",
"DM_SHARPENING",
"DM_SKIP"]
await barcodeScanner.updateRuntimeSettings(settings);
Changed Class Names of the Built-in UI elements
If you manipulated any of the built-in UI elements which are located by their class names, you need to update the class name(s) used in your code.
v7.x in dbr.scanner.html | v9.x in dbr.ui.html |
---|---|
dbrScanner-bg-loading |
dce-bg-loading |
dbrScanner-bg-camera |
dce-bg-camera |
dbrScanner-video |
dce-video |
dbrScanner-cvs-scanarea |
dce-scanarea |
dbrScanner-scanlight |
dce-scanlight |
dbrScanner-sel-camera |
dce-sel-camera |
dbrScanner-sel-resolutio |
dce-sel-resolution |
dbrScanner-btn-close |
dce-btn-close |
Other changes
The file dbr.scanner.html has been renamed to dbr.ui.html.
If you are still having issue with the upgrade, please contact us.