Table of Contents

Class QrCodeImage

Namespace
NuvTools.AspNetCore.Blazor.Components
Assembly
NuvTools.AspNetCore.Blazor.dll

Encodes text (a URL, a code, a payment payload) as a QR code image. Implemented here, with no dependency, so it runs in Blazor WebAssembly as well as on the server (for a PDF or an e-mail).

public static class QrCodeImage
Inheritance
QrCodeImage
Inherited Members

Remarks

UTF-8 text in byte mode, versions 1 to 40, the mask chosen by the standard penalty rules. NuvQrCode renders the same SVG as a component.

Methods

ToPng(string, int, QrCodeErrorCorrection, string, string, bool)

The QR code as PNG bytes.

public static byte[] ToPng(string value, int pixelsPerModule = 10, QrCodeErrorCorrection errorCorrection = QrCodeErrorCorrection.Medium, string darkColor = "#000000", string lightColor = "#ffffff", bool quietZone = true)

Parameters

value string

The text to encode.

pixelsPerModule int

Size of each module, in pixels.

errorCorrection QrCodeErrorCorrection

How much damage the code tolerates.

darkColor string

Colour of the modules, as #rrggbb or #rrggbbaa.

lightColor string

Background colour, as #rrggbb or #rrggbbaa.

quietZone bool

Whether to draw the blank margin scanners rely on.

Returns

byte[]

Exceptions

ArgumentException

The text is empty or too long, or a colour is not #rrggbb.

ToSvg(string, QrCodeErrorCorrection, string, string, bool)

The QR code as an SVG document that fills its container (it carries a viewBox, not a fixed size).

public static string ToSvg(string value, QrCodeErrorCorrection errorCorrection = QrCodeErrorCorrection.Medium, string darkColor = "#000000", string lightColor = "#ffffff", bool quietZone = true)

Parameters

value string

The text to encode.

errorCorrection QrCodeErrorCorrection

How much damage the code tolerates.

darkColor string

Colour of the modules, as #rrggbb.

lightColor string

Background colour, as #rrggbb.

quietZone bool

Whether to draw the blank margin scanners rely on. Leave it on unless the page already gives one.

Returns

string

Exceptions

ArgumentException

The text is empty or too long, or a colour is not #rrggbb.