Class SfBarcodeGenerator
Represents the class, which contains data and functionalities for SfBarcode.
Inheritance
Inherited Members
Namespace: Syncfusion.Blazor.BarcodeGenerator
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfBarcodeGenerator : SfBaseComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Examples
<SfBarcodeGenerator Width="200" Height="200" Value="65213323" Type="BarcodeType.Code11" BackgroundColor="white" ForeColor="black" EnableCheckSum="true" OnValidationFailed="@OnInvalid">
<BarcodeGeneratorDisplayText Text = "" Font="monospace" Size="25" Alignment="Alignment.Left" Position="TextPosition.Top">
<BarcodeTextMargin Left = "10" Top="10" Right="10" Bottom="10"></BarcodeTextMargin>
</BarcodeGeneratorDisplayText>
<BarcodeMargin Left = "10" Top="10" Right="10" Bottom="10"></BarcodeMargin>
</SfBarcodeGenerator>
@code{
public void OnInvalid(ValidationFailedEventArgs args)
{
}
}
Constructors
SfBarcodeGenerator()
Declaration
public SfBarcodeGenerator()
Properties
BackgroundColor
Specifies the background color of the barcode. By default, it is set to white.
Declaration
[Parameter]
public string BackgroundColor { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts the string value representing a CSS color code for the background color of barcode. The default value is white. |
ChildContent
Sets content for Barcode generator element including HTML support and its customizations.
Declaration
[Parameter]
public RenderFragment ChildContent { get; set; }
Property Value
| Type | Description |
|---|---|
| RenderFragment | Accepts a RenderFragment that defines the content of the UI element. |
DisplayText
Specifies the text properties for the barcode.
Declaration
[Parameter]
public BarcodeGeneratorDisplayText DisplayText { get; set; }
Property Value
| Type | Description |
|---|---|
| BarcodeGeneratorDisplayText | Displays a customized text of barcode. |
EnableCheckSum
Specifies an error detection in which some additional characters are added to a barcode to protect the integrity of barcode data. By default, it is set to true.
Declaration
[Parameter]
public bool EnableCheckSum { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ForeColor
Specifies the line and text color of the barcode. By default, it is set to black.
Declaration
[Parameter]
public string ForeColor { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts the string value. The default value is black. |
Height
Specifies the height of the barcode model.By default, it is set to 100%.
Declaration
[Parameter]
public string Height { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts the string value. The default value is |
Margin
Specifies the margin properties for the barcode. By default, it is set to 10 from all sides.
Declaration
[Parameter]
public BarcodeMargin Margin { get; set; }
Property Value
| Type | Description |
|---|---|
| BarcodeMargin | The margin of barcode, represented as a BarcodeMargin object. The default value of all side is |
OnValidationFailed
Triggers when the barcode input is an invalid string.
Declaration
[Parameter]
public EventCallback<ValidationFailedEventArgs> OnValidationFailed { get; set; }
Property Value
| Type |
|---|
| EventCallback<ValidationFailedEventArgs> |
Type
Specifies the type of barcode to be rendered. By default, it is set to Code128.
Declaration
[Parameter]
public BarcodeType Type { get; set; }
Property Value
| Type | Description |
|---|---|
| BarcodeType | One of the BarcodeType enumeration that specifies the type pf barcode generator. The default type is Code128. |
Value
Specifies the value of the barcode to be rendered.
Declaration
[Parameter]
public string Value { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts the string value. |
Width
Specifies the width of the barcode model. By default, it is set to 100%.
Declaration
[Parameter]
public string Width { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts the string value. The default value is |
Methods
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderTreeBuilder | __builder |
Overrides
Dispose()
It used to dispose the objects which are created in SfBarcodeGenerator.
Declaration
public override sealed void Dispose()
Overrides
Dispose(bool)
It used to dispose the objects which are created in SfBarcodeGenerator.
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
Overrides
Export(string, BarcodeExportType)
Export the barcode as an image in the specified image type and downloads it in the browser.
Declaration
public void Export(string fileName, BarcodeExportType exportType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | Specifies the filename of the barcode image to be download. |
| BarcodeExportType | exportType | Specifies the type used to export the barcode. |
ExportAsBase64Image(BarcodeExportType)
Export the barcode as an image in the specified image type and returns it as base64 string.
Declaration
public Task<string> ExportAsBase64Image(BarcodeExportType exportType)
Parameters
| Type | Name | Description |
|---|---|---|
| BarcodeExportType | exportType |
Returns
| Type | Description |
|---|---|
| Task<string> | Returns the base64 string value. |
OnAfterRenderAsync(bool)
The OnAfterRenderAsync method is invoked after the SfBarcodeGenerator component has finished rendering.
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | firstRender | The first time the component instance is rendered is set to true. |
Returns
| Type |
|---|
| Task |
Overrides
OnInitializedAsync()
OnInitializedAsync is invoked when the component is initialized.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type |
|---|
| Task |
Overrides
OnParametersSetAsync()
Sets the parameters for the SfBarcodeGenerator component in the render tree.
Declaration
protected override Task OnParametersSetAsync()
Returns
| Type |
|---|
| Task |