Skip to content

A Blazor wrapper for the JavaScript library bwip-js (Barcode Writer in Pure Javascript).

License

Notifications You must be signed in to change notification settings

ricardo-valero/Blazor.BwipJs

Repository files navigation

Blazor.BwipJs

A Blazor wrapper for the JavaScript library bwip-js (Barcode Writer in Pure Javascript)

Demo

https://ricardovalero95.github.io/Blazor.BwipJs/

Prerequisites

Getting Started

Installation

Install the package

dotnet add package Blazor.BwipJs

Assets

Add a reference to the JavaScript library in index.html (client-side) or _Host.cshtml (server-side) in the body tag after the _framework reference

<script src="https://cdn.jsdelivr.net/npm/bwip-js@2.1.1/dist/bwip-js.min.js"></script>

Imports

Add a reference to the package in _Imports.razor

@using Blazor.BwipJs

Services

Register the service

  • in Program.cs (client-side)
builder.Services.AddBlazorBwipJs();
  • or in Startup.cs (server-side)
services.AddBlazorBwipJs();

Usage

<Barcode BarcodeType="@BarcodeType"
         Text="@Text"
         IncludeText="@IncludeText"
         TextXAlign="@TextXAlign"
         TextYAlign="@TextYAlign"
         ScaleX="@ScaleX"
         ScaleY="@ScaleY"
         Height="@Height"
         Width="@Width"
         Rotate="@Rotate" />

References

This Blazor wrapper was built based on

Notes

  • This is a work in progress
  • I've only tested it with client-side Blazor Wasm
  • This is my first ever public repo, if you have any suggestions please contact me on Gitter or create an issue
  • I'm not experienced with GitHub Actions or Azure Pipelines if you want to help me with semantic releases and/or versioning please do
  • Other things I don't like are:
    • how Enums are used
    • handling JavaScript errors