barKoder Web SDK - Installation
Requirements #
WebAssembly is a type of code that can be run in modern web browsers — it is a low-level assembly-like language with a compact binary format that runs with near-native performance and is designed to run alongside JavaScript. The following requirements need to be met:
- Client: Chrome 64+, Firefox 69+, Edge 79+, Safari 13.1+, iOS Safari 13.4+Camera usage permission (if using startScanner)
- Chrome 64+, Firefox 69+, Edge 79+, Safari 13.1+, iOS Safari 13.4+
- Camera usage permission (if using startScanner)
- Server: HTTPS, MIME type for WASM files
- HTTPS, MIME type for WASM files
Install #
npm install barkoder-wasm
Install Manually #
If you would like to install from a local folder you will need to follow these steps:
- Download zip (get it here)
- Unpack zip file
- Rename folder to your liking
- Paste the folder in app directory i.e. myApp/barkoder-wasm (this is the new name of the download module folder)
- Finally in your cli (within your app's directory):
npm install "./barkoder-wasm"
Using the SDK #
Browser #
Copy both barkoder-umd.js and barkoder.wasm to your page's directory.
Include the barkoder-umd.js script:
<script type="text/javascript" src="barkoder-umd.js"></script>
CommonJS #
Copy barkoder.wasm to your page's directory (i.e. dist).
Require the UMD Module:
var BarkoderSDK = require('barkoder-wasm');
Then,
- In your js file:
async function barkoderInit () {
var Barkoder = await BarkoderSDK.initialize("your_license_key_here");
//enable symbologies you'd like to scan
Barkoder.setEnabledDecoders(
Barkoder.constants.Decoders.QR,
Barkoder.constants.Decoders.Ean8,
Barkoder.constants.Decoders.PDF417
);
//change any additional settings
Barkoder.setCameraResolution(Barkoder.constants.CameraResolution.FHD);
Barkoder.setDecodingSpeed(Barkoder.constants.DecodingSpeed.Normal);
}
barkoderInit(); //using await requires an async method
- In your HTML file add a div with barkoder-container id:
<div id="barkoder-container" style="width: 500px; height: 300px;"></div>
Additionally add style for size, position, background color, etc.Note that the container element needs to have a defined size, otherwise the SDK will set half the window size as fallback.
- Finally, you are ready to scan:
let callbackMethod = (result)=>alert(result.barcodeTypeName + '\n' + result.textualData);
Barkoder.startScanner(callbackMethod);
Barkoder.stopScanner();
Barkoder.scanImage('test.png', callbackMethod);
Make sure you have enabled the symbologies you wish to scan #
//enable symbologies you'd like to scan
Barkoder.setEnabledDecoders(
Barkoder.constants.Decoders.QR,
Barkoder.constants.Decoders.Ean8,
Barkoder.constants.Decoders.PDF417
);