Substantive.Blazor.QRCode 9.4.0-build20260114r2

Substantive.Blazor.QRCode

Reusable Blazor components and helpers for generating and decoding QR codes across WebAssembly and Server workloads. The library ships with UI components (QrCodeImage, QrCodeVector) plus the QRCodeUtils encoder/decoder utilities and the configurable QRCodeConfig record for fine-grained control.

Features

  • Image and SVG components: Drop-in Razor components that render PNG (Base64) or SVG QR codes with customizable colors, sizing, and optional logos.
  • Encoder helpers: Static helpers for producing Base64 strings, SVG markup, or PNG byte arrays for storage/streaming scenarios.
  • Decoder helpers: Stream, byte-array, and file-path helpers powered by ZXing for reading QR payloads from various image formats.
  • Configurable pipeline: Central QRCodeConfig record validates colors, pixels-per-module, quiet zones, and error-correction levels so QR codes remain scannable.

Getting Started

  1. Reference the project/package from your application.
  2. Import the namespace in _Imports.razor or the relevant Razor file:
    @using Substantive.Blazor.QRCode
    
  3. Add the component that fits your scenario:
    <QrCodeImage PayloadString="https://contoso.example" PixelsPerModule="16" DarkColor="#111" LightColor="#fafafa" />
    
    <QrCodeVector PayloadString="https://contoso.example" SvgLogo="@MySvgMarkup" />
    
  4. (Optional) Use QRCodeUtils directly when you need raw PNG bytes, SVG markup, or Base64 data URIs outside of component rendering.

Components

QrCodeImage

  • Renders a PNG-based QR code (data:image/png;base64,...).
  • Parameters: PayloadString, PixelsPerModule, DarkColor, LightColor, DrawQuietZone.
  • Adds the CSS class qr-code-container for custom styling; see the component-specific .razor.css for defaults.

QrCodeVector

  • Produces an SVG data URI, ideal for responsive layouts or printing scenarios.
  • Parameters mirror QrCodeImage with the addition of SvgLogo for inserting raw SVG content in the center of the code.
  • Uses QRCodeUtils.GenerateQRCodeAsSVG under the hood.

Utilities

Encoding (QRCodeUtils.Encoder)

  • GenerateQRCodeAsBase64(...): Returns a Base64 PNG string for inline <img> or CSS usage.
  • GenerateQRCodeAsSVG(...): Produces raw SVG markup; supports sizing modes and optional SVG logo overlays.
  • GenerateQRCodeAsPng(...): Returns PNG bytes suitable for persistence or streaming.
  • GenerateQRCodeAsByteArray(...): Core method invoked by the helpers above; validates QRCodeConfig via data annotations before generation.

QRCodeConfig highlights:

Property Description
DarkColor / LightColor HEX colors validated via regex; defaults #000 / #FFF.
PixelsModuleSize Resolution control (default 20).
DrawQuietZones Keeps scanners compatible with the required border.
ErrorCorrectionLevel Defaults to Q; raise to H when branding overlaps the code.
SvgIcon Optional raw SVG used when generating SVG codes with logos.

Decoding (QRCodeUtils.Decoder)

  • ReadQRCode(Stream) / ReadQRCode(byte[]): Decode payloads from in-memory content.
  • ReadQRCode(Stream, mediaType): Enforces a specific MIME type (image/png, image/jpeg, etc.).
  • ReadQRCode(string filePath): Automatically infers the image type from the file extension.

All decoding paths validate arguments, ensure readable streams, and throw precise exceptions when a QR code cannot be decoded.

Guidance & Best Practices

  • Prefer SVG output for responsive UIs; PNG/Base64 is great for quick inline rendering.
  • Keep DrawQuietZones enabled unless you control the background color tightly.
  • Use higher ErrorCorrectionLevel when overlaying logos or expecting wear/tear.
  • When decoding user-uploaded files, validate the stream (as done in QRCodeUtils) before attempting to decode.
  • If you contribute new public APIs, accompany them with xUnit tests and update this README when needed.

Support

File issues or feature requests in the Foundation Frontends repository. For security-sensitive concerns, follow the organization’s responsible disclosure guidelines.

Showing the top 20 packages that depend on Substantive.Blazor.QRCode.

Packages Downloads
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor components.
5
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor components.
6
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor components.
7
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor essential building blocks. It packed standalone Blazor components and extensions that often use such as Navigation, Exception Handling, Localization, etc,.
7

.NET 10.0

Version Downloads Last updated
9.4.0-build20260115R1 5 01/15/2026
9.4.0-build20260114R5 2 01/14/2026
9.4.0-build20260114R2 1 01/14/2026
9.4.0-build20260114R1 2 01/14/2026
9.4.0-build20260113R1 1 01/13/2026
9.4.0-build20260109R1 3 01/09/2026
9.4.0-build20251226R1 3 12/26/2025
9.3.3-build20251226R1 1 12/26/2025
9.3.2-build20251225R1 3 12/25/2025
9.3.0-build20251223R1 2 12/23/2025
9.2.0-build20251222R2 3 12/22/2025
9.2.0-build20251222R1 2 12/22/2025
9.1.0-build20251217R1 3 12/17/2025
9.1.0-build20251215R1 4 12/15/2025
9.1.0-build20251211R1 3 12/11/2025
9.1.0-build20251207R1 3 12/07/2025
9.1.0-build20251203R1 1 12/03/2025
9.1.0-build20251202R1 1 12/02/2025
9.1.0-build20251201R1 1 12/01/2025
9.1.0-build20251128R1 2 11/28/2025
9.0.4-build20251127R1 4 11/27/2025
9.0.4-build20251126R1 3 11/26/2025