BlazorBarcodes 1.0.5

dotnet add package BlazorBarcodes --version 1.0.5                
NuGet\Install-Package BlazorBarcodes -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorBarcodes" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorBarcodes --version 1.0.5                
#r "nuget: BlazorBarcodes, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorBarcodes as a Cake Addin
#addin nuget:?package=BlazorBarcodes&version=1.0.5

// Install BlazorBarcodes as a Cake Tool
#tool nuget:?package=BlazorBarcodes&version=1.0.5                

BlazorBarcodes

Provides blazor component for rendering 1D & 2D codes.

This is a really simple wrapper around huysentruitw´s Barcoder and as such supports the same barcode types, which at this time are:

  • 2 of 5
  • Aztec Code
  • Codabar
  • Code 39
  • Code 93
  • Code 128
  • Code 128 GS1
  • Data Matrix (ECC 200)
  • Data Matrix GS1
  • EAN 8
  • EAN 13
  • KIX (used by PostNL)
  • PDF 417
  • QR Code
  • RM4SC (Royal Mail 4 State Code)
  • UPC A
  • UPC E

Targets

.Net 5

Install

PM> Install-Package BlazorBarcodes

Demo

WASM

Usage

Add the following using statements.

@using BlazorBarcodes
@using BlazorBarcodes.Barcodes
@using BlazorBarcodes.Encoders

Pass a string content and either a BarcodeType(enum), Encoder or encoding function to the component.

<BarcodeComponent Style="width:200px;height:200px"
                    BarcodeType="@BarcodeTypes.DataMatrix"
                    Content="Hello World!">
</BarcodeComponent>

The codes are rendered as SVG by default.

If you´d like to quickly play around with the different barcodes, you create an easy selection like this.

<div style="display:flex; flex-direction:column">

    <input type="text" @bind="Content">

    <select @bind="Type">
        @foreach (var barcode in BarcoderWrapper.Barcodes.Barcode.All)
        {
            <option value="@barcode.Type" disabled="@(!barcode.Encoder.CanEncode(Content, out string error))">
                @(string.Format("{0}{1}", barcode.Name, error is not null ? $": {error}" : ""))
            </option>
        }
    </select>

    <BarcodeComponent Style="width:200px;height:200px"
                      BarcodeType="@Type"
                      Content="@Content">
    </BarcodeComponent>
</div>

@code {
    public BarcodeTypes Type { get; set; }

    public string Content { get; set; } = "";
}

Options

Passed to the Barcoder renderer

bool IncludeEANContentAsText

If you wish to display some sort of error message, in case of a rendering issue, pass an error template to the BarcodeComponent

<BarcodeComponent Style="width:200px;height:200px"
                    BarcodeType="@Type"
                    Content="@Content"
                    IncludeEANContentAsText="true">
    <ErrorTemplate>
        @context
    </ErrorTemplate>
</BarcodeComponent>

Encoders

The encoding functions in Barcoder have been wrapped in classes implementing my own IEncoder interface, since I wanted to be able to pass encoders around and also saw it as an opportunity to play around with C# source code generators.

You can still use pass the pre-existing encode methods to the component though.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.5 1,589 10/10/2022
1.0.4 2,504 2/19/2022
1.0.3 834 2/19/2022
1.0.2 848 2/19/2022
1.0.1 844 2/19/2022
1.0.0 858 2/19/2022