Migrating from DevExpress Barcode Controls to IronBarcode
DevExpress BarcodeからIronBarcodeへの移行
DevExpressのグリッド、チャート、スケジューラー、ピボットコントロールを使用している場合は、それらをそのまま使用してください。 このマイグレーションは、バーコードを読むことができ、ヘッドレスで実行でき、UIコンテキスト外でデプロイできるライブラリでBarCodeControlを置き換えることに特化しています。 WinFormsまたはBlazorアプリケーションで使用しているDevExpress UIコントロールは、今回の移行の影響を受けません。 バーコード固有のコードのみが変更されます。
この移行を促す典型的なシナリオは、次の3つのいずれかです。読み取り要件が発生したが、DevExpressではそれを満たすことができない。 新しいサービスでは、WinFormsアセンブリが存在しないASP.NET Coreまたはクラウド関数でバーコードを生成する必要があります。 あるいは、Suiteの更新時期が近づき、バーコード出力のためだけにフルUIツールキットを使用することの機能あたりのコスト計算が割に合わなくなる。
ステップ1: IronBarcodeをインストールする
dotnet add package BarCode
同じプロジェクト内に他のDevExpressコントロールも保持している場合は、DevExpress NuGetパッケージをそのままにしておいてください。 ソースファイル内のバーコード関連のコードのみが変更されます。 特定のプロジェクトにDevExpressを導入した唯一の理由がバーコード生成であり、そのプロジェクトで他のDXコントロールを使用していない場合は、移行後にそのプロジェクトからDevExpressパッケージを削除できます。
# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
# Only remove DevExpress packages if no other DX controls are used in this project
dotnet remove package DevExpress.Win.Navigation
ステップ2:ライセンス初期化を追加する
アプリケーションの起動時にIronBarcodeライセンスのアクティベーションを1度だけ追加します—App.xaml.cs、またはホストビルダーのいずれかに:
// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
// In Program.cs (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
Imports IronBarCode
' In Program.vb (ASP.NET Core) or application entry point
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"
ネットワーク呼び出しなし。 確認すべきエラーコードはありません。 ローカル検証。
ステップ3:バーコード固有のコードを置き換える
コードベース内でDevExpressバーコードタイプを検索します。それ以外のものはすべてそのまま残ります。
# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
# Find barcode-related DevExpress usage — ignore grid, chart, and other DX components
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator\|DevExpress.XtraPrinting.BarCode" --include="*.cs" .
grep -r "barCode\.Module\|DrawToBitmap\|BarCode\.Symbology" --include="*.cs" .
この検索結果は、まさにあなたが交換しようとしているものです。 それ以外は何もない。
コード移行の例
コード128生成
これは最も一般的な移住方法です。 BarcodeWriter.CreateBarcodeコールに変わります。
以前のバージョン — DevExpress WinForms コントロール:
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;
public void GenerateCode128(string data, string outputPath)
{
var barCode = new BarCodeControl();
var symbology = new Code128Generator();
symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
barCode.Symbology = symbology;
barCode.Text = data;
barCode.Module = 0.02f;
barCode.ShowText = true;
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(outputPath, ImageFormat.Png);
bitmap.Dispose();
}
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;
public void GenerateCode128(string data, string outputPath)
{
var barCode = new BarCodeControl();
var symbology = new Code128Generator();
symbology.CharacterSet = Code128CharacterSet.CharsetAuto;
barCode.Symbology = symbology;
barCode.Text = data;
barCode.Module = 0.02f;
barCode.ShowText = true;
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(outputPath, ImageFormat.Png);
bitmap.Dispose();
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging
Public Sub GenerateCode128(data As String, outputPath As String)
Dim barCode As New BarCodeControl()
Dim symbology As New Code128Generator()
symbology.CharacterSet = Code128CharacterSet.CharsetAuto
barCode.Symbology = symbology
barCode.Text = data
barCode.Module = 0.02F
barCode.ShowText = True
barCode.Width = 400
barCode.Height = 100
Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
bitmap.Save(outputPath, ImageFormat.Png)
bitmap.Dispose()
End Sub
後 — IronBarcode:
// NuGet: dotnet add package BarCode
using IronBarCode;
public void GenerateCode128(string data, string outputPath)
{
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.SaveAsPng(outputPath);
}
// NuGet: dotnet add package BarCode
using IronBarCode;
public void GenerateCode128(string data, string outputPath)
{
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.SaveAsPng(outputPath);
}
Imports IronBarCode
Public Sub GenerateCode128(data As String, outputPath As String)
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
.ResizeTo(400, 100) _
.SaveAsPng(outputPath)
End Sub
barCode.Module = 0.02fのドキュメント単位のサイズ設定はなくなりました。 .ResizeTo(400, 100)はピクセルを直接受け取ります。 手動の.SaveAsPng()に置き換えられます。
QRコード生成
以前 — DevExpress QR(エラー訂正機能付き):
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;
public void GenerateQrCode(string url, string outputPath)
{
var barCode = new BarCodeControl();
var symbology = new QRCodeGenerator();
symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
barCode.Symbology = symbology;
barCode.Text = url;
barCode.Width = 500;
barCode.Height = 500;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(outputPath, ImageFormat.Png);
bitmap.Dispose();
}
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
using System.Drawing;
using System.Drawing.Imaging;
public void GenerateQrCode(string url, string outputPath)
{
var barCode = new BarCodeControl();
var symbology = new QRCodeGenerator();
symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
barCode.Symbology = symbology;
barCode.Text = url;
barCode.Width = 500;
barCode.Height = 500;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(outputPath, ImageFormat.Png);
bitmap.Dispose();
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Imports System.Drawing
Imports System.Drawing.Imaging
Public Sub GenerateQrCode(url As String, outputPath As String)
Dim barCode As New BarCodeControl()
Dim symbology As New QRCodeGenerator()
symbology.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H
symbology.CompactionMode = QRCodeCompactionMode.AlphaNumeric
barCode.Symbology = symbology
barCode.Text = url
barCode.Width = 500
barCode.Height = 500
Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
bitmap.Save(outputPath, ImageFormat.Png)
bitmap.Dispose()
End Sub
後 — IronBarcode:
using IronBarCode;
public void GenerateQrCode(string url, string outputPath)
{
QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
.SaveAsPng(outputPath);
}
using IronBarCode;
public void GenerateQrCode(string url, string outputPath)
{
QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
.SaveAsPng(outputPath);
}
Imports IronBarCode
Public Sub GenerateQrCode(url As String, outputPath As String)
QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
.SaveAsPng(outputPath)
End Sub
QRCodeWriter.QrErrorCorrectionLevel.Highestにマップされます。 CompactionMode.AlphaNumeric設定は、コンテンツに基づいてIronBarcodeによって自動的に処理されます。
ブランドロゴ入りのQRコード(DevExpressでは不可能だった新機能):
using IronBarCode;
public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
.AddBrandLogo(logoPath)
.SaveAsPng(outputPath);
}
using IronBarCode;
public void GenerateBrandedQrCode(string url, string logoPath, string outputPath)
{
QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
.AddBrandLogo(logoPath)
.SaveAsPng(outputPath);
}
Imports IronBarCode
Public Sub GenerateBrandedQrCode(url As String, logoPath As String, outputPath As String)
QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
.AddBrandLogo(logoPath) _
.SaveAsPng(outputPath)
End Sub
データマトリックス生成
以前 — DevExpress:
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
var barCode = new BarCodeControl();
var symbology = new DataMatrixGenerator();
symbology.MatrixSize = DataMatrixSize.Matrix26x26;
barCode.Symbology = symbology;
barCode.Text = "PART-7734-X";
// ... DrawToBitmap pattern
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Dim barCode As New BarCodeControl()
Dim symbology As New DataMatrixGenerator()
symbology.MatrixSize = DataMatrixSize.Matrix26x26
barCode.Symbology = symbology
barCode.Text = "PART-7734-X"
' ... DrawToBitmap pattern
後 — IronBarcode:
using IronBarCode;
BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
.ResizeTo(260, 260)
.SaveAsPng("datamatrix.png");
using IronBarCode;
BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix)
.ResizeTo(260, 260)
.SaveAsPng("datamatrix.png");
Imports IronBarCode
BarcodeWriter.CreateBarcode("PART-7734-X", BarcodeEncoding.DataMatrix) _
.ResizeTo(260, 260) _
.SaveAsPng("datamatrix.png")
PDF417生成
以前 — DevExpress:
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
var barCode = new BarCodeControl();
barCode.Symbology = new PDF417Generator();
barCode.Text = "SHIPMENT-DATA-2026";
// ... DrawToBitmap pattern
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting.BarCode
Dim barCode As New BarCodeControl()
barCode.Symbology = New PDF417Generator()
barCode.Text = "SHIPMENT-DATA-2026"
' ... DrawToBitmap pattern
後 — IronBarcode:
using IronBarCode;
BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
.ResizeTo(400, 150)
.SaveAsPng("pdf417.png");
using IronBarCode;
BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417)
.ResizeTo(400, 150)
.SaveAsPng("pdf417.png");
Imports IronBarCode
BarcodeWriter.CreateBarcode("SHIPMENT-DATA-2026", BarcodeEncoding.PDF417) _
.ResizeTo(400, 150) _
.SaveAsPng("pdf417.png")
読書機能の追加(新規機能)
DevExpressは読み取り用APIを提供していません。 読書作業が必要になった場合、 IronBarcodeはすぐにその価値を発揮します。
using IronBarCode;
// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
Console.WriteLine($"Found {result.Format}: {result.Value}");
}
// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
using IronBarCode;
// Read from an image file
var results = BarcodeReader.Read("uploaded-label.png");
foreach (var result in results)
{
Console.WriteLine($"Found {result.Format}: {result.Value}");
}
// Read with options for better accuracy on difficult images
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
MaxParallelThreads = 4
};
var detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
Imports IronBarCode
' Read from an image file
Dim results = BarcodeReader.Read("uploaded-label.png")
For Each result In results
Console.WriteLine($"Found {result.Format}: {result.Value}")
Next
' Read with options for better accuracy on difficult images
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True,
.MaxParallelThreads = 4
}
Dim detailedResults = BarcodeReader.Read("multi-barcode-sheet.png", options)
ASP.NET Coreバーコードエンドポイント
これは、WinFormsの回避策なしではBarCodeControlで実現できませんでした。 IronBarcodeはこれをネイティブにサポートしています。
using IronBarCode;
// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.ToPngBinaryData();
return Results.File(pngBytes, "image/png", $"{sku}.png");
});
app.MapGet("/qr/{data}", (string data) =>
{
var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
.ToPngBinaryData();
return Results.File(pngBytes, "image/png");
});
using IronBarCode;
// In Program.cs or a controller
app.MapGet("/label/{sku}", (string sku) =>
{
var pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.ToPngBinaryData();
return Results.File(pngBytes, "image/png", $"{sku}.png");
});
app.MapGet("/qr/{data}", (string data) =>
{
var pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest)
.ToPngBinaryData();
return Results.File(pngBytes, "image/png");
});
Imports IronBarCode
' In Program.vb or a controller
app.MapGet("/label/{sku}", Function(sku As String)
Dim pngBytes = BarcodeWriter.CreateBarcode(sku, BarcodeEncoding.Code128) _
.ResizeTo(400, 100) _
.ToPngBinaryData()
Return Results.File(pngBytes, "image/png", $"{sku}.png")
End Function)
app.MapGet("/qr/{data}", Function(data As String)
Dim pngBytes = QRCodeWriter.CreateQrCode(data, 300, QRCodeWriter.QrErrorCorrectionLevel.Highest) _
.ToPngBinaryData()
Return Results.File(pngBytes, "image/png")
End Function)
PDFファイルからバーコードを読み取る
IronBarcodeはPDFファイルをネイティブに読み込むことができます。 PdfiumViewerなし、レンダリングループなし、追加パッケージなし:
using IronBarCode;
// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}
using IronBarCode;
// Read all barcodes from all pages of a PDF
var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}");
}
Imports IronBarCode
' Read all barcodes from all pages of a PDF
Dim results = BarcodeReader.Read("shipping-manifest.pdf")
For Each result In results
Console.WriteLine($"Barcode: {result.Value} | Format: {result.Format}")
Next
よくある移行の問題
barCode.Moduleはピクセルではなくドキュメント単位を使用します
barCode.Moduleは、ドキュメント単位で最も狭いバーの幅を制御します(レンダリングDPIコンテキストに依存)。 これはピクセル数ではありません。 マイグレーションする際に、モジュール値をピクセルに変換しようとせず、必要なピクセル寸法を決定し、.ResizeTo(width, height)を直接使用してください。
// Before: barCode.Module = 0.02f — document units, indirect sizing
// After:
.ResizeTo(400, 100) // explicit pixel dimensions
// Before: barCode.Module = 0.02f — document units, indirect sizing
// After:
.ResizeTo(400, 100) // explicit pixel dimensions
' Before: barCode.Module = 0.02F — document units, indirect sizing
' After:
.ResizeTo(400, 100) ' explicit pixel dimensions
DrawToBitmapには、事前に割り当てられたビットマップが必要です
以前のパターンは、特定のサイズのDrawToBitmapを呼び出しました。 IronBarcodeの.SaveAsPng()は、これをすべて内部で処理します。 事前に何も割り当てる必要はありません。
// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();
// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.SaveAsPng(path);
// Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400;
barCode.Height = 100;
var bitmap = new Bitmap(barCode.Width, barCode.Height);
barCode.DrawToBitmap(bitmap, new Rectangle(0, 0, barCode.Width, barCode.Height));
bitmap.Save(path, ImageFormat.Png);
bitmap.Dispose();
// After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.SaveAsPng(path);
' Before: must know size upfront, allocate, draw, save, dispose
barCode.Width = 400
barCode.Height = 100
Dim bitmap As New Bitmap(barCode.Width, barCode.Height)
barCode.DrawToBitmap(bitmap, New Rectangle(0, 0, barCode.Width, barCode.Height))
bitmap.Save(path, ImageFormat.Png)
bitmap.Dispose()
' After: size specified once, everything else handled
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
.ResizeTo(400, 100) _
.SaveAsPng(path)
WinFormsのデータバインディング
WinFormsデザイナーでBarcodeWriter.CreateBarcodeに渡すことです。 IronBarcodeはWinFormsのデータバインディングには参加しません。これはUIコントロールではなく、プログラムによるAPIです。 生成されたバーコードをフォームに表示する必要がある場合、画像バイトを生成し、それらをPictureBoxに設定します:
using IronBarCode;
// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.ToPngBinaryData();
using var ms = new System.IO.MemoryStream(bytes);
pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}
using IronBarCode;
// Generate and display in a WinForms PictureBox
private void UpdateBarcodeDisplay(string value)
{
var bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128)
.ResizeTo(400, 100)
.ToPngBinaryData();
using var ms = new System.IO.MemoryStream(bytes);
pictureBox1.Image = System.Drawing.Image.FromStream(ms);
}
Imports IronBarCode
Imports System.IO
' Generate and display in a WinForms PictureBox
Private Sub UpdateBarcodeDisplay(value As String)
Dim bytes = BarcodeWriter.CreateBarcode(value, BarcodeEncoding.Code128) _
.ResizeTo(400, 100) _
.ToPngBinaryData()
Using ms As New MemoryStream(bytes)
pictureBox1.Image = System.Drawing.Image.FromStream(ms)
End Using
End Sub
名前空間の置換
削除する古いインポート:
// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
// Remove these
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting.BarCode;
新たにインポートする項目:
// Add this
using IronBarCode;
// Add this
using IronBarCode;
Imports IronBarCode
APIマッピングリファレンス
| DevExpress バーコード | IronBarcode相当品 |
|---|---|
new BarCodeControl() |
静的 - インスタンスなし |
new Code128Generator() + barCode.Symbology = symbology |
BarcodeEncoding.Code128 パラメーター |
new QRCodeGenerator() + QRCodeErrorCorrectionLevel.H |
QRCodeWriter.CreateQrCode(data, size, QRCodeWriter.QrErrorCorrectionLevel.Highest) |
new DataMatrixGenerator() + DataMatrixSize.Matrix26x26 |
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.DataMatrix) |
new PDF417Generator() |
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.PDF417) |
new AztecCodeGenerator() |
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Aztec) |
barCode.Text = value |
CreateQrCodeへの最初の引数 |
barCode.Module = 0.02f |
ピクセルでの.ResizeTo(width, height) |
barCode.ShowText = true |
.AddBarcodeText() |
DrawToBitmap(bitmap, rect) |
.SaveAsPng(path) |
new Bitmap(w, h) + 手動破棄 |
不要 |
ビットマップ → MemoryStream → HTTP |
.ToPngBinaryData() |
| 読み取りAPIはありません | BarcodeReader.Read(path) |
using DevExpress.XtraEditors + using DevExpress.XtraPrinting.BarCode |
using IronBarCode |
移行チェックリスト
更新が必要なすべてのファイルを見つけるには、次のgrepパターンを使用してください。
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
grep -r "BarCodeControl\|Code128Generator\|QRCodeGenerator\|DataMatrixGenerator\|PDF417Generator\|AztecCodeGenerator" --include="*.cs" .
grep -r "barCode\.Module\|barCode\.Symbology\|DrawToBitmap\|DevExpress\.XtraPrinting\.BarCode" --include="*.cs" .
各試合を順に進めてください。
using IronBarCode;に置き換えますnew BarCodeControl()+ シンボロジー設定をBarcodeWriter.CreateBarcode(data, BarcodeEncoding.X)に置き換えますnew QRCodeGenerator()+ シンボロジー設定をQRCodeWriter.CreateQrCode(data, size, errorLevel)に置き換えます.ResizeTo(width, height)に置き換えますDrawToBitmap+.SaveAsPng(path)に置き換えます- ビットマップからメモリストリームへのパターンを
.ToPngBinaryData()に置き換えます - アプリケーションの起動時に
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"を追加します - 読み取り機能が必要な場所に
BarcodeReader.Read()コールを追加します
プロジェクトでDevExpressをバーコード制御のみに使用し、その他のDXコンポーネントを使用していない場合は、すべてのバーコード参照を置き換えた後、DevExpress NuGetパッケージを削除してください。 プロジェクトでDevExpressのグリッド、チャート、またはその他のUIコントロールを使用している場合は、それらのパッケージはそのままにしておいてください。今回の移行ではバーコードコードのみが影響を受けます。
よくある質問
なぜDevExpress BarCodeからIronBarcodeに移行する必要があるのですか?
一般的な理由としては、ライセンスの簡素化(SDK + ランタイムキーの複雑さの排除)、スループット制限の排除、ネイティブPDFサポートの獲得、Docker/CI/CDデプロイの改善、プロダクションコード内のAPI定型文の削減などが挙げられます。
DevExpressのAPIコールをIronBarcodeに置き換えるには?
インスタンスの作成とライセンスの定型文をIronBarCode.License.LicenseKey = "key "に置き換えてください。リーダー・コールをBarcodeReader.Read(path)に、ライター・コールをBarcodeWriter.CreateBarcode(data, encoding)に置き換えてください。静的メソッドはインスタンス管理を必要としません。
DevExpress BarCodeからIronBarcodeに移行する場合、コードはどのくらい変更されますか?
ほとんどのマイグレーションでは、コード行数は少なくなります。ライセンスの定型文、インスタンス・コンストラクタ、明示的なフォーマット設定が削除されます。コアとなる読み取り/書き込み操作は、より短いIronBarcodeに対応し、よりきれいな結果オブジェクトが得られます。
移行中、DevExpress BarCodeとIronBarcodeの両方をインストールしておく必要がありますか?
ほとんどのマイグレーションは、並列操作ではなく、直接置き換えです。一度に1つのサービスクラスを移行し、NuGet参照を置き換え、インスタンス化とAPI呼び出しパターンを更新してから次のクラスに移行します。
IronBarcodeのNuGetパッケージ名は何ですか?
パッケージは'IronBarcode'(大文字のBとC)です。Install-Package IronBarcode'または'dotnet add package IronBarcode'でインストールしてください。コード中のusingディレクティブは'using IronBarcode;'である。
IronBarcodeはDevExpress Barcodeと比較して、どのようにDockerデプロイを簡素化しますか?
IronBarcodeは外部SDKファイルやマウントされたライセンス設定のないNuGetパッケージです。Dockerでは、IRONBARCODE_LICENSE_KEY環境変数を設定すると、パッケージが起動時にライセンス検証を処理します。
DevExpressから移行した後、IronBarcodeはすべてのバーコードフォーマットを自動的に検出しますか?
IronBarcodeは、サポートされているすべてのフォーマットのシンボルを自動検出します。明示的なBarcodeTypesの列挙は必要ありません。フォーマットが既に知られていて、パフォーマンスが重要な場合、BarcodeReaderOptionsは最適化として検索空間を制限することができます。
IronBarcodeは別のライブラリなしでPDFからバーコードを読み取ることができますか?
BarcodeReader.Read("document.pdf")は、PDFファイルをネイティブに処理します。結果には、見つかった各バーコードの PageNumber、Format、Value、および Confidence が含まれます。外部のPDFレンダリングステップは必要ありません。
IronBarcodeはどのようにパラレルバーコード処理を行うのですか?
IronBarcodeの静的メソッドはステートレスでスレッドセーフです。Parallel.ForEachをスレッドごとのインスタンス管理なしにファイルリスト上で直接使用します。BarcodeReaderOptions.MaxParallelThreadsは内部のスレッドバジェットを制御します。
DevExpress BarCodeからIronBarcodeに移行すると、どのような結果のプロパティが変更されますか?
一般的なリネーム:BarcodeValueはValueに、BarcodeTypeはFormatに。IronBarcodeの結果にはConfidenceとPageNumberも追加されます。ソリューション全体の検索と置換は、既存の結果処理コードで名前の変更を処理します。
CI/CDパイプラインでIronBarcodeのライセンスを設定するには?
IRONBARCODE_LICENSE_KEYをパイプラインシークレットとして保存し、アプリケーションの起動コードにIronBarCode.License.LicenseKeyを割り当てます。1つのシークレットで、開発環境、テスト環境、ステージング環境、本番環境を含むすべての環境をカバーできます。
IronBarcodeはカスタムスタイルのQRコード生成に対応していますか?
はい。QRCodeWriter.CreateQrCode()は、ChangeBarCodeColor()によるカスタムカラー、AddBrandLogo()によるロゴ埋め込み、設定可能なエラー訂正レベル、PNG、JPG、PDF、ストリームなどの複数の出力形式をサポートしています。

