Table of Contents

Class SymbolSvg

Namespace
TwBlazor.Services.Encoding
Assembly
TwBlazor.dll

Draws any IEncodedSymbol (QR codes and barcodes alike) as SVG.

public static class SymbolSvg
Inheritance
SymbolSvg
Inherited Members

Remarks

Each horizontal run of dark modules becomes one rectangle in a single path, so the DOM holds one element however large the symbol is. One unit of the drawing is one module wide; the rows of a one-dimensional barcode are stretched to the bar height.

Methods

GetSvgPath(IEncodedSymbol, int?, int)

Builds the SVG path data for the dark modules, offset by the quiet zone.

public static string GetSvgPath(this IEncodedSymbol symbol, int? quietZone = null, int barHeight = 50)

Parameters

symbol IEncodedSymbol

The encoded symbol.

quietZone int?

The light margin, in modules, or null for the symbol's own.

barHeight int

The bar height of a one-dimensional barcode, in modules.

Returns

string

The value for a path's d attribute.

GetSvgViewBox(IEncodedSymbol, int?, int)

Gets the SVG viewBox that fits the symbol and its quiet zone.

public static string GetSvgViewBox(this IEncodedSymbol symbol, int? quietZone = null, int barHeight = 50)

Parameters

symbol IEncodedSymbol

The encoded symbol.

quietZone int?

The light margin, in modules, or null for the symbol's own.

barHeight int

The bar height of a one-dimensional barcode, in modules.

Returns

string

The value for an SVG's viewBox attribute.

ToSvg(IEncodedSymbol, SymbolSvgOptions?)

Builds a standalone SVG document for the symbol, for saving, emailing or embedding outside a component.

public static string ToSvg(this IEncodedSymbol symbol, SymbolSvgOptions? options = null)

Parameters

symbol IEncodedSymbol

The encoded symbol.

options SymbolSvgOptions

The colors, sizes, caption and title, or null for Default.

Returns

string

The SVG markup.

ToSvgDataUri(IEncodedSymbol, SymbolSvgOptions?)

Builds a data:image/svg+xml URI for the symbol, usable as a download link or an <img> source.

public static string ToSvgDataUri(this IEncodedSymbol symbol, SymbolSvgOptions? options = null)

Parameters

symbol IEncodedSymbol

The encoded symbol.

options SymbolSvgOptions

The colors, sizes, caption and title, or null for Default.

Returns

string

The data URI.