Table of Contents

Interface ITwBarcodeService

Namespace
TwBlazor.Services
Assembly
TwBlazor.dll

Encodes values into one-dimensional barcodes, with no third-party dependencies.

public interface ITwBarcodeService

Remarks

Encoding produces a Barcode, a plain row of dark and light modules. Draw it with the SymbolSvg methods (ToSvg, ToSvgDataUri, GetSvgPath) or your own renderer. TwBarcode uses this service to show a barcode on the page. The service is stateless and safe to share.

Methods

Encode(string, BarcodeFormat)

Encodes a value as a barcode.

Barcode Encode(string value, BarcodeFormat format = BarcodeFormat.Code128)

Parameters

value string

The value to encode.

format BarcodeFormat

The barcode format. Defaults to Code128.

Returns

Barcode

The encoded barcode.

Exceptions

ArgumentNullException

value is null.

SymbolEncodingException

The value cannot be encoded in format.

TryEncode(string?, BarcodeFormat, out Barcode?)

Tries to encode a value as a barcode, without throwing when the value does not suit the format.

bool TryEncode(string? value, BarcodeFormat format, out Barcode? barcode)

Parameters

value string

The value to encode.

format BarcodeFormat

The barcode format.

barcode Barcode

The encoded barcode, or null when the value cannot be encoded.

Returns

bool

true when the value was encoded.