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 在生成條形碼時提供許多選項和自訂功能。 無論您是開發獨立的條形碼生成器以生成具有標準編碼格式的圖像,如MemoryStream,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天試用金鑰
無需信用卡或帳戶建立