RadzenBarcode Class

A 1D barcode generator component that renders barcodes as SVG graphics. Generates barcodes entirely client-side (no external dependencies).

Inheritance

Object

ComponentBase

RadzenComponent

RadzenBarcode

Implements

IComponent

IHandleEvent

IHandleAfterRender

Namespace: Radzen.Blazor

Assembly: Radzen.Blazor.dll

Syntax

public class RadzenBarcode : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender

Examples

<RadzenBarcode Value="RADZEN-12345" Type="RadzenBarcodeType.Code128" Height="80px" />

Constructors

RadzenBarcodeLink to this section

A 1D barcode generator component that renders barcodes as SVG graphics. Generates barcodes entirely client-side (no external dependencies).

Declaration
public RadzenBarcode()

Properties

BackgroundLink to this section

Gets or sets the barcode background color.

Declaration
public string Background { get; set; }
Property Value
Type Description
stringGets or sets the barcode background color.

BarHeightLink to this section

Gets or sets the height of the bars in SVG units (viewBox units). Default is 50.

Declaration
public double BarHeight { get; set; }
Property Value
Type Description
doubleGets or sets the height of the bars in SVG units (viewBox units). Default is 50.

FontSizeLink to this section

Gets or sets the font size for layout calculations of the value text (in SVG viewBox units). This is not automatically applied as an SVG attribute; use ValueStyle to style the text.

Declaration
public double FontSize { get; set; }
Property Value
Type Description
doubleGets or sets the font size for layout calculations of the value text (in SVG viewBox units). This is not automatically applied as an SVG attribute; use ValueStyle to style the text.

ForegroundLink to this section

Gets or sets the barcode bars color.

Declaration
public string Foreground { get; set; }
Property Value
Type Description
stringGets or sets the barcode bars color.

HeightLink to this section

Gets or sets the rendered height of the SVG. Accepts CSS units (e.g. "80px"). If ShowValue is true, the text is drawn inside this height.

Declaration
public string Height { get; set; }
Property Value
Type Description
stringGets or sets the rendered height of the SVG. Accepts CSS units (e.g. "80px"). If ShowValue is true, the text is drawn inside this height.

QuietZoneModulesLink to this section

Gets or sets the quiet zone in modules (left and right padding).

Declaration
public int QuietZoneModules { get; set; }
Property Value
Type Description
intGets or sets the quiet zone in modules (left and right padding).

ShowChecksumLink to this section

Gets or sets whether to show the checksum (if applicable for the selected Type) under the bars.

Declaration
public bool ShowChecksum { get; set; }
Property Value
Type Description
boolGets or sets whether to show the checksum (if applicable for the selected Type) under the bars.

ShowValueLink to this section

Gets or sets whether to show the value as text under the bars.

Declaration
public bool ShowValue { get; set; }
Property Value
Type Description
boolGets or sets whether to show the value as text under the bars.

TextMarginTopLink to this section

Gets or sets the gap between bars and text in SVG units (viewBox units).

Declaration
public double TextMarginTop { get; set; }
Property Value
Type Description
doubleGets or sets the gap between bars and text in SVG units (viewBox units).

TypeLink to this section

Gets or sets the barcode type.

Declaration
public RadzenBarcodeType Type { get; set; }
Property Value
Type Description
RadzenBarcodeTypeGets or sets the barcode type.

ValueLink to this section

Gets or sets the barcode value to encode.

Declaration
public string Value { get; set; }
Property Value
Type Description
stringGets or sets the barcode value to encode.

ValueStyleLink to this section

Gets or sets the value inline CSS style.

Declaration
public string ValueStyle { get; set; }
Property Value
Type Description
stringGets or sets the value inline CSS style.

WidthLink to this section

Gets or sets the rendered width of the SVG. Accepts CSS units (e.g. "300px", "100%").

Declaration
public string Width { get; set; }
Property Value
Type Description
stringGets or sets the rendered width of the SVG. Accepts CSS units (e.g. "300px", "100%").

Methods

BuildRenderTreeLink to this section

Declaration
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
Parameters
Type Name Description
Rendering.RenderTreeBuilder __builder

GetComponentCssClassLink to this section

Gets the component CSS class.

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

HasChecksumLink to this section

Gets whether the specified barcode type produces a checksum value that can be displayed when ShowChecksum is enabled.

Declaration
public static bool HasChecksum(RadzenBarcodeType type)
Parameters
Type Name Description
RadzenBarcodeType type The barcode type.
Returns
Type Description
booltrue if the type has a checksum value; otherwise, false.

ToPngLink to this section

Renders the barcode as a PNG image and downloads it in the browser.

Declaration
public Task ToPng(string fileName, int? width, int? height)
Parameters
Type Name Description
string fileName The download file name. Default is barcode.png.
int? width The PNG width in pixels. When omitted the rendered size scaled by the device pixel ratio is used.
int? height The PNG height in pixels. When omitted it is derived from width preserving the aspect ratio.
Returns
Type Description
Task

ToPngLink to this section

Renders the barcode as a PNG image and downloads it in the browser.

Declaration
public Task<Byte[]> ToPng(int? width, int? height)
Parameters
Type Name Description
int? width The PNG width in pixels. When omitted the rendered size scaled by the device pixel ratio is used.
int? height The PNG height in pixels. When omitted it is derived from width preserving the aspect ratio.
Returns
Type Description
Task<Byte[]>

ToSvgLink to this section

Returns the SVG markup of the rendered barcode as a string.

Declaration
public Task<string> ToSvg()
Returns
Type Description
Task<string>A Task<T> representing the asynchronous operation. The task result contains the SVG markup of the barcode.
An error has occurred. This app may no longer respond until reloaded. Reload 🗙