RazorBarcodeLibrary 1.0.0
Please use the built-in Dynamsoft JavaScript SDK directly within your Blazor project to access the full range of functionalities.
dotnet add package RazorBarcodeLibrary --version 1.0.0
NuGet\Install-Package RazorBarcodeLibrary -Version 1.0.0
<PackageReference Include="RazorBarcodeLibrary" Version="1.0.0" />
paket add RazorBarcodeLibrary --version 1.0.0
#r "nuget: RazorBarcodeLibrary, 1.0.0"
// Install RazorBarcodeLibrary as a Cake Addin #addin nuget:?package=RazorBarcodeLibrary&version=1.0.0 // Install RazorBarcodeLibrary as a Cake Tool #tool nuget:?package=RazorBarcodeLibrary&version=1.0.0
Razor Barcode Library
A Razor Class Library, equipped with the Dynamsoft JavaScript Barcode SDK, enables the creation of web-based barcode reader and scanner applications entirely in C#.
Online Demo
https://yushulx.me/Razor-Barcode-Library/
Demo Video
https://github.com/yushulx/Razor-Barcode-Library/assets/2202306/ac3c333f-7895-420a-94ee-6debe805a8b7
Prerequisites
Quick Usage
Import and initialize the Razor Barcode Library.
@using RazorBarcodeLibrary protected override async Task OnInitializedAsync() { barcodeJsInterop = new BarcodeJsInterop(JSRuntime); await barcodeJsInterop.LoadJS(); }
Set the license key and load the wasm module.
await barcodeJsInterop.SetLicense('LICENSE-KEY'); await barcodeJsInterop.LoadWasm();
Create a barcode reader instance.
BarcodeReader reader = await barcodeJsInterop.CreateBarcodeReader();
Read barcodes from a base64 image source.
List<BarcodeResult> results = await reader.DecodeBase64(imageSrc); string text = ""; foreach (BarcodeResult result in results) { text += "format: " + result.Format + ", "; text += "text: " + result.Text + "<br>"; }
Create a barcode scanner instance and set the callback function.
@implements BarcodeScanner.ICallback BarcodeReader reader = await barcodeJsInterop.CreateBarcodeScanner(); await scanner.RegisterCallback(this); public async Task OnCallback(List<BarcodeResult> results) {}
Open the camera and start scanning.
<div id="videoContainer"></div> await scanner.SetVideoElement("videoContainer"); List<Camera> cameras = await scanner.GetCameras(); await scanner.OpenCamera(cameras[0]);
API
Camera Class
Represents a camera device with its device ID and label.
BarcodeResult Class
Represents the result of a barcode scan, including the decoded text, format, and positional details.
BarcodeJsInterop Class
Provides JavaScript interop functionalities for barcode operations.
Task LoadJS()
: Loads and initializes the JavaScript module.Task SetLicense(string license)
: Sets the license key for the barcode functionality.Task LoadWasm()
: Loads the WebAssembly for barcode processing.Task<BarcodeReader> CreateBarcodeReader()
: Creates a new BarcodeReader instance.Task<BarcodeScanner> CreateBarcodeScanner()
: Creates a new BarcodeScanner instance.Task DrawCanvas(string id, int sourceWidth, int sourceHeight, List<BarcodeResult> results)
: Draws the barcode results on a specified canvas.Task ClearCanvas(string id)
: Clears the specified canvas element.
BarcodeReader Class
Provides functionalities to decode barcodes from various sources such as Base64 strings and canvas objects.
Task<List<BarcodeResult>> DecodeBase64(string base64)
: Asynchronously decodes a barcode from a Base64 encoded string.Task<List<BarcodeResult>> DecodeCanvas(IJSObjectReference canvas)
: Asynchronously decodes a barcode from a canvas object.Task<string> GetParameters()
: Asynchronously retrieves the current parameters of the barcode reader.Task<int> SetParameters(string parameters)
: Asynchronously sets the parameters for the barcode reader.
BarcodeScanner Class
Provides functionalities for barcode scanning using a camera.
Task SetVideoElement(string videoId)
: Sets a div element as the video container.Task OpenCamera(Camera camera)
: Opens the camera for barcode scanning.Task CloseCamera()
: Closes the current camera.Task<List<Camera>> GetCameras()
: Gets a list of available cameras.Task RegisterCallback(ICallback callback)
: Registers a callback for handling barcode scan results.
Example
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net7.0
- Microsoft.AspNetCore.Components.Web (>= 7.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
- Added barcode scanner API.