syncfusion-blazor-barcode

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Syncfusion Blazor Barcode Generator

Syncfusion Blazor 条码生成器

Syncfusion's Blazor Barcode Generator package (
Syncfusion.Blazor.BarcodeGenerator
) provides three components for generating barcodes in Blazor applications:
ComponentUse For
SfBarcodeGenerator
1D linear barcodes (Code39, Code128, Codabar, etc.)
SfQRCodeGenerator
QR codes with optional logo embedding
SfDataMatrixGenerator
2D Data Matrix codes for compact encoding
All three work in Blazor Server, Blazor WebAssembly, and Blazor Web App (.NET 8+).

Syncfusion的Blazor条码生成器包(
Syncfusion.Blazor.BarcodeGenerator
)提供三个组件,用于在Blazor应用中生成条码:
组件适用场景
SfBarcodeGenerator
一维线性条码(Code39、Code128、Codabar等)
SfQRCodeGenerator
可嵌入Logo的QR码
SfDataMatrixGenerator
用于紧凑编码的二维Data Matrix码
这三个组件均支持Blazor ServerBlazor WebAssemblyBlazor Web App(.NET 8+)。

When to Use This Skill

何时使用该技能

  • User needs to render or display a barcode in a Blazor component
  • User asks about QR code generation (e.g., product links, 2FA, contact cards)
  • User needs Data Matrix codes (pharmaceutical, logistics, label printing)
  • User is configuring
    SfBarcodeGenerator
    ,
    SfQRCodeGenerator
    , or
    SfDataMatrixGenerator
  • User asks about exporting a barcode as an image (JPG/PNG) or Base64
  • User asks about barcode types, error correction, checksums, or validation events
  • User is embedding a logo in a QR code

  • 用户需要在Blazor组件中渲染或显示条码
  • 用户询问QR码生成相关问题(如产品链接、双因素认证、联系人卡片)
  • 用户需要生成Data Matrix码(制药、物流、标签打印场景)
  • 用户正在配置
    SfBarcodeGenerator
    SfQRCodeGenerator
    SfDataMatrixGenerator
  • 用户询问如何将条码导出为图片(JPG/PNG)或Base64格式
  • 用户询问条码类型、纠错机制、校验和或验证事件相关内容
  • 用户需要在QR码中嵌入Logo

Navigation Guide

导航指南

Setting Up the Project

项目设置

📄 Read: references/getting-started.md
  • NuGet package installation
  • _Imports.razor
    namespace configuration
  • Service registration in
    Program.cs
  • Stylesheet and script references
  • Setup for Blazor Server, WebAssembly, and Web App
  • Adding the first barcode component to a page
📄 阅读: references/getting-started.md
  • NuGet包安装
  • _Imports.razor
    命名空间配置
  • Program.cs
    中的服务注册
  • 样式表和脚本引用
  • Blazor Server、WebAssembly和Web App的设置步骤
  • 在页面中添加第一个条码组件

1D Barcode Types and Configuration

一维条码类型与配置

📄 Read: references/barcode-types.md
  • All supported
    BarcodeType
    enum values with descriptions
  • Code39, Code39 Extended, Code11, Code32, Code93, Codabar, Code128
  • Choosing the right type for your use case
  • EnableCheckSum
    configuration
  • OnValidationFailed
    event handling
📄 阅读: references/barcode-types.md
  • 所有受支持的
    BarcodeType
    枚举值及说明
  • Code39、Code39扩展码、Code11、Code32、Code93、Codabar、Code128
  • 根据使用场景选择合适的条码类型
  • EnableCheckSum
    配置
  • OnValidationFailed
    事件处理

QR Code Generator

QR码生成器

📄 Read: references/qr-code-generator.md
  • Basic QR code usage
  • Error correction levels (L, M, Q, H)
  • Embedding a logo image in the QR code center
  • Customizing logo size
  • Color, dimension, and display text customization
  • OnValidationFailed
    event
📄 阅读: references/qr-code-generator.md
  • QR码基础用法
  • 纠错等级(L、M、Q、H)
  • 在QR码中心嵌入Logo图片
  • 自定义Logo尺寸
  • 颜色、尺寸和显示文本自定义
  • OnValidationFailed
    事件

Data Matrix Generator

Data Matrix码生成器

📄 Read: references/data-matrix-generator.md
  • Basic Data Matrix code usage
  • Color, dimension, and display text customization
  • Common use cases (pharmaceuticals, labels)
  • OnValidationFailed
    event
📄 阅读: references/data-matrix-generator.md
  • Data Matrix码基础用法
  • 颜色、尺寸和显示文本自定义
  • 常见使用场景(制药、标签)
  • OnValidationFailed
    事件

Exporting and Customizing Barcodes

条码导出与自定义

📄 Read: references/export-and-customization.md
  • Export barcode to image file (JPG/PNG)
  • Export as Base64 string
  • ForeColor
    for custom barcode color
  • Width
    /
    Height
    for sizing
  • BarcodeGeneratorDisplayText
    for label text
  • Applies to all three generator types

📄 阅读: references/export-and-customization.md
  • 将条码导出为图片文件(JPG/PNG)
  • 导出为Base64字符串
  • 自定义条码颜色的
    ForeColor
    属性
  • 用于调整尺寸的
    Width
    /
    Height
    属性
  • 用于标签文本的
    BarcodeGeneratorDisplayText
    属性
  • 以上配置适用于所有三个生成器组件

Quick Start Examples

快速入门示例

1D Barcode

一维条码

razor
@using Syncfusion.Blazor.BarcodeGenerator

<SfBarcodeGenerator Width="200px" Height="150px"
                    Type="@BarcodeType.Code128"
                    Value="SYNCFUSION">
</SfBarcodeGenerator>
razor
@using Syncfusion.Blazor.BarcodeGenerator

<SfBarcodeGenerator Width="200px" Height="150px"
                    Type="@BarcodeType.Code128"
                    Value="SYNCFUSION">
</SfBarcodeGenerator>

QR Code

QR码

razor
@using Syncfusion.Blazor.BarcodeGenerator

<SfQRCodeGenerator Width="200px" Height="200px"
                   Value="https://www.syncfusion.com">
</SfQRCodeGenerator>
razor
@using Syncfusion.Blazor.BarcodeGenerator

<SfQRCodeGenerator Width="200px" Height="200px"
                   Value="https://www.syncfusion.com">
</SfQRCodeGenerator>

Data Matrix

Data Matrix码

razor
@using Syncfusion.Blazor.BarcodeGenerator

<SfDataMatrixGenerator Width="200" Height="150"
                       Value="SYNCFUSION">
</SfDataMatrixGenerator>

razor
@using Syncfusion.Blazor.BarcodeGenerator

<SfDataMatrixGenerator Width="200" Height="150"
                       Value="SYNCFUSION">
</SfDataMatrixGenerator>

Key Properties

关键属性

PropertyApplies ToDescription
Value
AllThe data string to encode
Width
AllWidth of the barcode (px or %)
Height
AllHeight of the barcode (px or %)
Type
SfBarcodeGenerator
BarcodeType
enum — selects the 1D symbology
ForeColor
AllColor of the barcode bars (e.g.,
"red"
,
"#333"
)
EnableCheckSum
SfBarcodeGenerator
Adds/validates checksum digit (default
true
for Code39)
ErrorCorrectionLevel
SfQRCodeGenerator
QR error recovery: Low, Medium, Quartile, High
OnValidationFailed
AllEvent triggered when
Value
contains invalid characters

属性适用组件说明
Value
所有组件要编码的数据字符串
Width
所有组件条码宽度(px或%)
Height
所有组件条码高度(px或%)
Type
SfBarcodeGenerator
BarcodeType
枚举——选择一维条码符号体系
ForeColor
所有组件条码条的颜色(例如
"red"
"#333"
EnableCheckSum
SfBarcodeGenerator
添加/验证校验和数字(Code39默认值为
true
ErrorCorrectionLevel
SfQRCodeGenerator
QR码纠错等级:Low、Medium、Quartile、High
OnValidationFailed
所有组件
Value
包含无效字符时触发的事件

Common Use Cases

常见使用场景

NeedComponentRead
Product/inventory labels
SfBarcodeGenerator
(Code128/Code39)
barcode-types.md
URL / contact / 2FA QR code
SfQRCodeGenerator
qr-code-generator.md
Branded QR code with logo
SfQRCodeGenerator
+
QRCodeLogo
qr-code-generator.md
Pharmaceutical / shipping labels
SfDataMatrixGenerator
data-matrix-generator.md
Download barcode as image
.Export()
method
export-and-customization.md
Embed barcode in email/PDF
.ExportAsBase64Image()
export-and-customization.md
需求组件参考文档
产品/库存标签
SfBarcodeGenerator
(Code128/Code39)
barcode-types.md
URL / 联系人 / 双因素认证QR码
SfQRCodeGenerator
qr-code-generator.md
带Logo的品牌化QR码
SfQRCodeGenerator
+
QRCodeLogo
qr-code-generator.md
制药/运输标签
SfDataMatrixGenerator
data-matrix-generator.md
将条码下载为图片
.Export()
方法
export-and-customization.md
在邮件/PDF中嵌入条码
.ExportAsBase64Image()
export-and-customization.md