IRONSOFTWAREHOME
樣式條碼
using IronBarCode;
using IronSoftware.Drawing;

// Create a barcode
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// Resize in pixels
myBarcode.ResizeTo(400, 100);

// Set margins in pixels
myBarcode.SetMargins(5, 5, 5, 5);

// Set the color of the barcode
myBarcode.ChangeBarCodeColor(Color.Red);

// And save our barcode as an image:
myBarcode.SaveAsImage("EAN8.jpeg");

// Another supported feature is Mil Sizing
// Mil is a measurement unit used by the barcode scanner manufacturers to specify the minimum of one barcode bar, and at what distance the barcode can be scanned.
// It represents (1 / 1000)th of an inch
var barcodeResizeInMils = BarcodeWriter.CreateBarcode("5941623002802", BarcodeEncoding.Code128);

// This will resize the barcode width to 13 mil, at 96 DPI by default
barcodeResizeInMils.ResizeToMil(13);

// This will resize the barcode width to 10 mil and and the height to 1.5 inches, at 96 DPI by default
barcodeResizeInMils.ResizeToMil(10, 1.5);

// This will resize the barcode width to 7.5 mil and the height to 2 inches, with the DPI set to 200
barcodeResizeInMils.ResizeToMil(7.5, 2, 200);
Imports IronBarCode
Imports IronSoftware.Drawing

' Create a barcode
Dim myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

' Resize in pixels
myBarcode.ResizeTo(400, 100)

' Set margins in pixels
myBarcode.SetMargins(5, 5, 5, 5)

' Set the color of the barcode
myBarcode.ChangeBarCodeColor(Color.Red)

' And save our barcode as an image:
myBarcode.SaveAsImage("EAN8.jpeg")

' Another supported feature is Mil Sizing
' Mil is a measurement unit used by the barcode scanner manufacturers to specify the minimum of one barcode bar, and at what distance the barcode can be scanned.
' It represents (1 / 1000)th of an inch
Dim barcodeResizeInMils = BarcodeWriter.CreateBarcode("5941623002802", BarcodeEncoding.Code128)

' This will resize the barcode width to 13 mil, at 96 DPI by default
barcodeResizeInMils.ResizeToMil(13)

' This will resize the barcode width to 10 mil and and the height to 1.5 inches, at 96 DPI by default
barcodeResizeInMils.ResizeToMil(10, 1.5)

' This will resize the barcode width to 7.5 mil and the height to 2 inches, with the DPI set to 200
barcodeResizeInMils.ResizeToMil(7.5, 2, 200)
NuGet Download
PM > Install-Package BarCode
樣式條碼

樣式條碼

使用IronBarcode,您可以靈活地調整條碼大小、增加邊距、更改顏色,並以各種熱門檔案格式儲存它們。 此外,您可以調整DPI設置,以達到更細緻的影像控制。

自定義條碼外觀:多種方法允許修改條碼的大小和顏色:

  • ResizeTo(500, 500):將條碼調整為500x500像素。
  • ChangeBarColor:改變條碼中條的顏色。
  • ChangeBackgroundColor:更改背景顏色。
學習如何使用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天試用金鑰
無需信用卡或帳戶建立