Lyo.Barcode
2.0.1
dotnet add package Lyo.Barcode --version 2.0.1
NuGet\Install-Package Lyo.Barcode -Version 2.0.1
<PackageReference Include="Lyo.Barcode" Version="2.0.1" />
<PackageVersion Include="Lyo.Barcode" Version="2.0.1" />
<PackageReference Include="Lyo.Barcode" />
paket add Lyo.Barcode --version 2.0.1
#r "nuget: Lyo.Barcode, 2.0.1"
#:package Lyo.Barcode@2.0.1
#addin nuget:?package=Lyo.Barcode&version=2.0.1
#tool nuget:?package=Lyo.Barcode&version=2.0.1
Lyo.Barcode
Contracts for generating and decoding barcodes: IBarcodeService, request and options models, plus BarcodeBuilder. Companion packages such as Lyo.Barcode.Native own concrete rendering and symbology.
Examples
First generate call
using Lyo.Barcode;
using Lyo.Barcode.Models;
// Assume IBarcodeService is registered (e.g. Native implementation).
IBarcodeService barcodes = /* ... */;
var result = await barcodes.GenerateAsync(
"HELLO-128",
BarcodeSymbology.Code128,
new BarcodeOptions { Format = BarcodeFormat.Svg, ModuleWidthPixels = 2, BarHeightPixels = 64 });
if (result.IsSuccess && result is BarcodeResult br && br.ImageBytes != null)
await File.WriteAllBytesAsync("out.svg", br.ImageBytes);
Build with the fluent API
var (data, sym, opts) = BarcodeBuilder.New()
.WithData("SKU-12345")
.WithSymbology(BarcodeSymbology.Code128)
.WithFormat(BarcodeFormat.Bmp)
.WithModuleWidthPixels(2)
.WithBarHeightPixels(96)
.WithShowHumanReadableTextBelow(true)
.WithShowBorder(true)
.WithBorderWidthPixels(4)
.WithBorderColorHex("#000000")
.Build();
await barcodes.GenerateAsync(data, sym, opts);
Read a barcode from image bytes
var read = await barcodes.ReadFromImageAsync(pngBytes);
if (read.IsSuccess && read.Data != null)
Console.WriteLine(read.Data.Text);
Public types
| Type | Description |
|---|---|
| IBarcodeService | Build barcodes from a string or BarcodeBuilder, write them to a stream or file, run a batch, and decode raster bytes. |
| BarcodeBuilder | Fluent builder for payload, BarcodeSymbology, and BarcodeOptions (module width, colors, human-readable text, border). |
| BarcodeRequest | One batch item: Data, Symbology, optional Options, optional Id. |
| BarcodeOptions | Raster/SVG size, colors, quiet zone, caption under the bars, optional border frame. |
| BarcodeServiceOptions | Limits and defaults implementations inherit from the host. See SectionName. |
| BarcodeResult | Result<BarcodeRequest> carrying ImageBytes, dimensions, and format. |
| BarcodeImageReadResult | What the decoder returns: Text, FormatName. |
| BarcodeSymbology, BarcodeFormat | Symbologies and output formats that are supported. |
| BarcodeErrorCodes | Stable failure code strings. |
How the border is drawn
If BarcodeOptions.ShowBorder is true, Lyo.Barcode.Native grows width and height by 2 × BorderWidthPixels and paints a filled frame in BorderColorHex around the symbol. The usual background and bars stay the same inside that inset. BarcodeServiceOptions.MinBorderWidthPixels / MaxBorderWidthPixels clamp the width (defaults 1 to 64). When the border is on, BorderColorHex must be #RGB or #RRGGBB.
Binding from configuration
Implementations can bind BarcodeServiceOptions from the BarcodeService section (see BarcodeServiceOptions.SectionName).
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Exceptions(direct, lyo)Lyo.Metrics(direct, lyo)Lyo.Result(direct, lyo)Microsoft.Extensions.Logging.Abstractions10.0.5(direct, microsoft)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Lyo.Exceptions (>= 2.0.0)
- Lyo.Metrics (>= 2.0.0)
- Lyo.Result (>= 2.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Lyo.Barcode:
| Package | Downloads |
|---|---|
|
Lyo.Barcode.Web.Components
Reusable Blazor components for barcode generation and preview workflows. |
|
|
Lyo.Barcode.Native
Native barcode implementation for Lyo.Barcode - includes Code128 encoding, image rendering, and ZXing-based barcode reading. |
GitHub repositories
This package is not used by any popular GitHub repositories.