Interface ITwBarcodeService
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
valuestringThe value to encode.
formatBarcodeFormatThe barcode format. Defaults to Code128.
Returns
- Barcode
The encoded barcode.
Exceptions
- ArgumentNullException
valueis 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
valuestringThe value to encode.
formatBarcodeFormatThe barcode format.
barcodeBarcodeThe encoded barcode, or null when the value cannot be encoded.