IRONSOFTWAREHOME
設置條碼邊距
using IronBarCode;

// Specify Code 128 Format
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128);

// Add barcode value text below the barcode
barcode.AddBarcodeValueTextBelowBarcode();

// Save it as JPG
barcode.SaveAsJpeg("code128-sample.jpg");
Imports IronBarCode

' Specify Code 128 Format
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128)

' Add barcode value text below the barcode
barcode.AddBarcodeValueTextBelowBarcode()

' Save it as JPG
barcode.SaveAsJpeg("code128-sample.jpg")
NuGet Download
PM > Install-Package BarCode
設置條碼邊距

設置條碼邊距

條碼的邊距是指圍繞程式碼的空白區域。 此區域對於掃描器的可靠性至關重要。 它使掃描器能夠識別barcodebeginsandends的位置,從而將其與附近的文字或圖形分隔開。 如果邊距不正確,掃描可能會失敗或錯讀資料。 在這個程式碼範例中,我們將展示如何使用IronBarcode為條碼設置一致的邊距以確保可讀性。

設置條碼邊距的3步指南

  • using IronBarCode;
  • GeneratedBarcode qrcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode);
  • qrcode.SetMargins(100);

程式碼解釋

首先我們導入IronBarcode程式庫,然後使用BarcodeWriter.CreateBarcode方法生成一個條碼。 我們向該方法傳遞兩個參數:字串值和條碼的型別。 在上面的例子中,這些分別是"https://ironsoftware.com/csharp/barcode"和`BarcodeWriterEncoding.QRCode`。

建立SetMargins方法。 我們傳遞一個整數值,它表示以像素為單位的邊距。 在此情況下,100將100像素的靜默區應用到生成的QR碼的四個邊。

發現如何通過詳細指南提升您的條碼設計!
在 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天試用金鑰
無需信用卡或帳戶建立