Class SymbolSvg
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
symbolIEncodedSymbolThe encoded symbol.
quietZoneint?The light margin, in modules, or null for the symbol's own.
barHeightintThe bar height of a one-dimensional barcode, in modules.
Returns
- string
The value for a path's
dattribute.
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
symbolIEncodedSymbolThe encoded symbol.
quietZoneint?The light margin, in modules, or null for the symbol's own.
barHeightintThe bar height of a one-dimensional barcode, in modules.
Returns
- string
The value for an SVG's
viewBoxattribute.
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
symbolIEncodedSymbolThe encoded symbol.
optionsSymbolSvgOptions
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
symbolIEncodedSymbolThe encoded symbol.
optionsSymbolSvgOptions
Returns
- string
The data URI.