Table of Contents

Interface ITwQrCodeService

Namespace
TwBlazor.Services
Assembly
TwBlazor.dll

Encodes text or bytes into QR codes, with no third-party dependencies.

public interface ITwQrCodeService

Remarks

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

Methods

Encode(byte[], QrEncodeOptions?)

Encodes raw bytes into a QR code.

QrMatrix Encode(byte[] data, QrEncodeOptions? options = null)

Parameters

data byte[]

The bytes to encode.

options QrEncodeOptions

The encoding settings, or null for Default.

Returns

QrMatrix

The encoded matrix.

Exceptions

ArgumentNullException

data is null.

SymbolEncodingException

The data does not fit at the requested error correction level.

Encode(string, QrEncodeOptions?)

Encodes text into a QR code, using the densest mode the text allows (numeric, alphanumeric or UTF-8 bytes).

QrMatrix Encode(string value, QrEncodeOptions? options = null)

Parameters

value string

The text to encode, for example a URL.

options QrEncodeOptions

The encoding settings, or null for Default.

Returns

QrMatrix

The encoded matrix.

Exceptions

ArgumentNullException

value is null.

SymbolEncodingException

The text does not fit at the requested error correction level.

TryEncode(string?, QrEncodeOptions?, out QrMatrix?)

Tries to encode text into a QR code, without throwing when it is too long.

bool TryEncode(string? value, QrEncodeOptions? options, out QrMatrix? matrix)

Parameters

value string

The text to encode.

options QrEncodeOptions

The encoding settings, or null for Default.

matrix QrMatrix

The encoded matrix, or null when the text does not fit.

Returns

bool

true when the text was encoded.