Interface ITwQrCodeService
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
databyte[]The bytes to encode.
optionsQrEncodeOptions
Returns
- QrMatrix
The encoded matrix.
Exceptions
- ArgumentNullException
datais 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
valuestringThe text to encode, for example a URL.
optionsQrEncodeOptions
Returns
- QrMatrix
The encoded matrix.
Exceptions
- ArgumentNullException
valueis 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
valuestringThe text to encode.
optionsQrEncodeOptionsmatrixQrMatrixThe encoded matrix, or null when the text does not fit.