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
valuestringThe text to encode.
pixelsPerModuleintSize of each module, in pixels.
errorCorrectionQrCodeErrorCorrectionHow much damage the code tolerates.
darkColorstringColour of the modules, as
#rrggbbor#rrggbbaa.lightColorstringBackground colour, as
#rrggbbor#rrggbbaa.quietZoneboolWhether 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
valuestringThe text to encode.
errorCorrectionQrCodeErrorCorrectionHow much damage the code tolerates.
darkColorstringColour of the modules, as
#rrggbb.lightColorstringBackground colour, as
#rrggbb.quietZoneboolWhether to draw the blank margin scanners rely on. Leave it on unless the page already gives one.
Returns
Exceptions
- ArgumentException
The text is empty or too long, or a colour is not
#rrggbb.