IRONSOFTWAREHOME
创建条码
using IronBarCode;
using System.IO;

// Create a barcode with one line of code
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// Save the barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg");

// A barcode can also be made from binary data (byte or stream)
string payloadAsString = "This is some random string";

byte[] payloadAsByteArray = System.Text.Encoding.Default.GetBytes(payloadAsString); // Byte array
var AztecBarcode = BarcodeWriter.CreateBarcode(payloadAsByteArray, BarcodeWriterEncoding.Aztec, 400, 400); // Create from Byte array

MemoryStream payloadAsStream = new MemoryStream(payloadAsByteArray); // MemoryStream
var AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400); // Create from memory stream
Imports IronBarCode
Imports System.IO

' Create a barcode with one line of code
Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

' Save the barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg")

' A barcode can also be made from binary data (byte or stream)
Dim payloadAsString As String = "This is some random string"

Dim payloadAsByteArray As Byte() = System.Text.Encoding.Default.GetBytes(payloadAsString) ' Byte array
Dim AztecBarcode = BarcodeWriter.CreateBarcode(payloadAsByteArray, BarcodeWriterEncoding.Aztec, 400, 400) ' Create from Byte array

Dim payloadAsStream As New MemoryStream(payloadAsByteArray) ' MemoryStream
Dim AztecBarcode2 = BarcodeWriter.CreateBarcode(payloadAsStream, BarcodeWriterEncoding.Aztec, 400, 400) ' Create from memory stream
NuGet Download
PM > Install-Package BarCode
创建条码

创建条码

IronBarcode 在生成条形码方面提供了许多选项和自定义功能。 无论您是在开发一个独立的条形码生成器以生成带有标准编码格式的图像,如jpeg

BarcodeWriter.CreateBarcode

在实例化BarcodeWriter.CreateBarcode来创建条形码。 该方法需要两个参数:一个BarcodeWriterEncoding枚举。 然后我们将条形码保存为图像以供后续使用。

除了创建条形码,IronBarcode还允许开发者将多个方法链在一起以便于使用,如第3行所示。它创建一个条形码,然后调用SaveAsImage

此外,BarcodeWriter.CreateBarcode方法有多种变体可以满足不同情况和场景的需求。 如果您需要基于ByteArray作为值,并事先指定条形码的高度和宽度。

类似地,如果您需要创建具有MemoryStream类型变量的条形码,IronBarcode也提供了这种功能; 如上所述,将BarcodeWriter.CreateBarcode的第一个参数传递,然后重复步骤。

IronBarcode 为希望创建简单条形码值、将其集成到应用程序中等的开发人员准备了所有选项和场景!

学习如何创建自定义条形码图像
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 2,422,100版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户